w2utils.locale

Loads a new locale.
locale(locale, [keepPhrases]);
Returns a promise.
locale string or path or object or array, name of the locale or path to the locale file, or settings object with the locale
keepPhrases boolean, optional, keep phrases when mergin locale objects

Description

The first parameter can be a string or a path to the file or an object or an array of strings/pathes. If it is a string (ex: ru-ru) it is the name of the locale. It will attempt to load the JSON file from the /locale folder. If you want to load locale file from some other folder, you need to provide full path to it. If it's an object than the settings object will be extended with properties of this locale object. If it's an array of strings or pathes, all JSON files will be loaded in order and then be merged.
The method will perform synchronous load of the locale, so it will pause until locale is loaded.
You can call in in the following way:

User Comments

comments powered by Disqus