Socket
Socket
Sign inDemoInstall

@box/i18n

Package Overview
Dependencies
3
Maintainers
28
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @box/i18n

i18n utilities for box frontend projects


Version published
Weekly downloads
3
increased by200%
Maintainers
28
Install size
100 kB
Created
Weekly downloads
 

Readme

Source

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.

FAQs

Last updated on 19 Oct 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc