
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
locator-lang
Advanced tools
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.
Install using npm:
$ npm install locator-lang
The examples below show how to use the plugin with locator.
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 namelang is the language tag (e.g., en-US)langBundleName is 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 = require('locator'),
LocatorLang = require('locator-lang'),
loc = new Locator({ buildDirectory: 'build' });
// using locator-lang plugin
loc.plug(new LocatorLang({
format: 'yui',
defaultLang: 'en',
transpiler: 'yrb',
requiredLangs: ['en', 'es', 'fr']
}));
transpiler configurationAs today, only one transpiler called yrb is supported, by default it will apply
a simple JSON.parse.
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.
This transpiler relies on intl-messageformat to parse YRB pattern strings into JavaScript that can be used to create language resource bundles which are ultimately used to fill localized templates.
format configurationThe only format supported as today is yui. In this example above, each language bundle will be compiled into files containing YUI modules under the build folder.
defaultLang configurationThis 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 foo_en.js.
requiredLangs configurationThe 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 requiredLangs configuration.
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.
FAQs
Language bundles compiler for locator
The npm package locator-lang receives a total of 8 weekly downloads. As such, locator-lang popularity was classified as not popular.
We found that locator-lang demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
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.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.