Language bundle compiler for Locator.
When you plug the locator-lang plugin instance into the locator instance,
locator will identify any
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.
Install using npm:
$ npm install locator-lang
The examples below show how to use the plugin with locator.
var Locator =LocatorLang =loc = ;// using locator-lang pluginloc;
This example compiles any lang file into memory and exposes it through
bundleNameis the name that locator assigns to every bundle based on the npm package name
langis the language tag (e.g.,
langBundleNameis derived from the file name from where the language entries were extracted.
There are few configuration arguments that can be passed when creating a plugin instance. Here is an example:
var Locator =LocatorLang =loc = buildDirectory: 'build' ;// using locator-lang pluginloc;
As today, only one transpiler called
yrb is supported, by default it will apply
YRB pattern strings are externalized into resource bundles and localized by translators, while the arguments and locale are provided by the software at runtime. The use of patterns enables localization in meaningful translation units (at least complete sentences) with reordering of arguments and omission of arguments that are not relevant to some languages.
The only format supported as today is
yui. In this example above, each language bundle will be compiled into files containing YUI modules under the
This value defines what language to use when a lang bundle source file does not
include the locale as part of the filename. In this example above, for a file like
path/lang/foo.json, a new file will be generated as
requiredLangs configuration specifies an array of required languags. If this value is set, the plugin will complete language bundles and/or entries based on the
defaultLang. In other words, if you haven't done the translation for a particular language, the plugin will fallback to the default language bundle by using the default values as the values for the missing language. The same happen for individual entries in each language bundle, and the plugin will be able to analyze each file, and fallback to a default entry/message when it is missing in a particular language bundle. This guarantee that your application can assume all entries/messages and lang bundles are in place for all the languages in the
This software is free to use under the Yahoo! Inc. BSD license. See the LICENSE file for license text and copyright information.
See the CONTRIBUTING file for info.