Localization Module (NodeJS and Browser)
- MaskJS Localization Util
- Localization Function
Node.js
Resolve language from the current request(middleware)
Browser
Resolve language from navigator.language
or location.query ('/?language=en')
If the language is not supported, the default one is taken.
Formatter
Atma-Formatter is used to format/interpolate strings.
Pluralization
Refer to the atma-formatter
.
Usage
Mask Util
~[L: ID [,...expressions]]
~[L: (expression) [,...expressions]]
-
Simple:
~[L:fooId]
-
Formatting:
Example:
header > '~[L:welcomeId, name]'// same asheader > '~[L:"welcomeId", name]'$L;mask; -
get i18n ID from model: Example:
var menu = [ 'todo', 'task' ]ul$L;mask;
Function
Browser @see examples
;
Node
connect
Configuration
IncludeJS
Browser
Load this library with IncludeJS - after defining the list of supported languages and the path to translations, it will load also supported translations
include ;
NodeJS
Use the middleware
function so that not all translations are loaded at once, but only with the first incomming request.
(c) MIT, Atma.js Project