kivra-copy-consumer

1.0.3 • Public • Published

Kivra copy consumer

Reusable copy consumption logic for Kivra frontend services

Get started

npm i --save kivra-copy-consumer
import { fetchCopy } from 'kivra-copy-consumer'

fetchCopy({
  'en-US': 'https://example.com/us-copy.json'
},
{
  useBrowserLocale: true,
  fallbackLocale: 'en-US',
  defaultCopyPath: '/copy-default.json'
}).then(copy => {
  // use copy ...
})

Which locale is used?

In order of prioritization:

  • if locale GET param is set in URL, copy is fetched for that locale
  • if useBrowserLocale is true, use locale prefered by browser
  • otherwise use fallbackLocale

Which file is fetched

  • If an url for the chosen locale was passed then that is fetched. If the fetch fails we instead fetch defaultCopyPath.
  • If no url for the chosen locale was passed then the url for fallbackLocale is fetched

/kivra-copy-consumer/

    Package Sidebar

    Install

    npm i kivra-copy-consumer

    Weekly Downloads

    0

    Version

    1.0.3

    License

    ISC

    Unpacked Size

    27.2 kB

    Total Files

    16

    Last publish

    Collaborators

    • tatsii
    • timjackleus
    • lambdalainen
    • kivra-dev
    • biggestt