New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

icuify

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

icuify

Browserify tool to transform ICU resource bundles to JS objects

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

icuify

A browserify transformer to convert ICU bundles into JSON.

installation

npm install icuify

Usage

ICUify will use the icu-converter tool to convert your resource bundles into JSON formats. A simple example is:

browserify -t [ icuify --ext=.txt ] strings/en/messages.txt

However you can also directly include the resource bundle in your JS code:

# test.js
var msgs = require('strings/en/messages.txt');
console.log(msgs);
$ browserify -t [ icuify --ext=.txt ] test.js

If you have multiple resource bundles (for example, different languages), then you can use the require-globify transformer to make your life easy.

Say you have a directory structure like this:

strings/en/messages.txt
strings/fr/messages.txt

Using the require-globify tool you can do the following in your js code:

# test.js
var msgs = require('strings/**/*.txt', { expand: 'hash' });
console.log(msgs);

Then run browserify like so:

$ browserify -t [ icuify --ext=.txt ] -t [ require-globify ] test.js > bundle.js
$ node bundle.js

You will then see output similar to:

{
    "en/messsages": {
        "root": {
            "hello": "Hello"
        }
    },
    "fr/messages": {
        "root": {
            "hello": "Bon Jour"
        }
    }
}

The JSON that is created can be used on its own, however if you want to use the pluralization/gender/etc features of the ICU format, you'll have to use another tool that will process them. Recommended is the excellent MessageFormat tool available at: https://github.com/messageformat/messageformat.js

Examples

There are two basic examples showing single and multi file usage. Both projects are built using Grunt. To run either one do the following:

$ npm install
$ grunt
$ node cli.js

Keywords

browserify

FAQs

Package last updated on 30 Sep 2016

Did you know?

Socket

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