npm

Need private packages and team management tools?Check out npm Orgs. »

This package has been deprecated

Author message:

Use @box/frontend

@box/i18n

0.1.1 • Public • Published

npm version

Frontend related i18n utilities used by other Box frontend projects. Unless you are a part of another Box project, you should not be consuming any code from here. It is completely unsupported and can be highly unstable.

Publishing

This project is published on public npmjs. To push a new release, use yarn release:major or yarn release:minor or yarn release:patch.

Locales

Returns an array of locales supported by Box.

const locales = require('@box/i18n/locales.js');
locales.forEach(...);

TranslationsPlugin.js

Uses the below buildTranslations script as part of the webpack build process. Use this plugin within your project's webpack config.

1st argument should be the folder containing properties files. 2nd argument should be the folder containing the json output from react-intl's babel plugin.

const TranslationsPlugin = require('@box/i18n/TranslationsPlugin.js');
const i18n = path.resolve('i18n'); // Where the .properties files are dumped
const jsonDir = path.join(i18n, 'json'); // Where the react-intl plugin dumps json
 
...
  plugins: [
    ...,
    new TranslationsPlugin(i18n, jsonDir)
    ...
  ]
...

props2es.js

Uses the below buildTranslations script as a standalone node script. Use this standalone script to build translations on demand.

1st argument should be the folder containing properties files. 2nd argument should be the folder containing the json output from react-intl's babel plugin.

package.json

...
  scripts: {
    ...,
    "build:i18n": "node ./node_modules/@box/i18n/props2es.js ./i18n ./i18n/json"
    ...
  }
...

buildTranslations.js

You should ideally not be using this script directly. It is used by the webpack TranslationsPlugin and props2es.js script file as mentioned above.

  1. Reads json output from react-intl's babel plugin.
  2. Writes the en-US.properties file from that json output.
  3. Reads all locale specific properties files.
  4. Writes corresponding js files for each locale.

Keywords

none

install

npm i @box/i18n

Downloadsweekly downloads

1

version

0.1.1

license

see license in LICENSE

last publish

collaborators

    Report a vulnerability