Locator plugin to compile language bundles
JavaScript
Pull request Compare This branch is 59 commits behind yahoo:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
lib
.gitignore
.npmignore
.travis.yml
CONTRIBUTE.md
HISTORY.md
LICENSE
README.md
package.json

README.md

locator-lang

Language bundle compiler for Locator.

When you plug the locator-lang plugin instance into the locator instance, locator will identify any lang/*.js, lang/*.json, or lang/*.json5 files as language bundles, and provision them as locator bundle objects.

This plugin also supports the compilation of language bundles into formats that can be delivered to the client. Currently, the only supported format is the YUI module format, but we plan to add more output formats (e.g., amd, es6, etc) in the future.

Build Status

Installation

Install using npm:

$ npm install locator-lang

Usage

The examples below show how to use the plugin with locator.

Compiling language bundles into memory

var Locator = require('locator'),
    LocatorLang = require('locator-lang'),
    loc = new Locator();

// using locator-lang plugin
loc.plug(new LocatorLang());

This example compiles any lang file into memory and exposes it through loc.getBundle('<bundleName>').lang['<lang>']['<langBundleName>'].

  • bundleName is the name that locator assigns to every bundle based on the npm package name
  • lang is the language tag (e.g., en-US)
  • langBundleName is derived from the file name from where the language entries were extracted.

Compiling language bundles into YUI modules

var Locator = require('locator'),
    LocatorLang = require('locator-lang'),
    loc = new Locator({ buildDirectory: 'build' });

// using locator-lang plugin
loc.plug(new LocatorLang({ format: 'yui' }));

In this example, each language bundle will be compiled into files containing YUI modules under the build folder.

License

This software is free to use under the Yahoo! Inc. BSD license. See the LICENSE file for license text and copyright information.

Contribute

See the CONTRIBUTE file for info.