For reasons of time and advancement in technologies, especially JS, this project is no longer maintained.
We personally think this is a good example of simplifying JS code in Node for these purposes and hopefully we'll have enough time to come back to this idea or something similar.
This project has favored great relationships and has provided a lot of learning for its participants
See you later! <3
Very simple internationalization (aka i18n) manager for Node.js
Textualization offers the possibility of not writing any user text message in your JS code. Allows to translate your code into any language without having to learn a complex methodology.
var message = "User " + username + " has been disconnected at " + time + ".";
var message = i18n.translate(
"User %s has been disconnected at %s",
[user.firstName+" "+user.lastName, time.toUTCString()],
language
);
And a translation sheet entry similar to:
...
"User %s %s has been disconnected at %s." = "El usuario %s %s se ha desconectado a las %s.";
...
...
var message = i18n('user.messages.logOut',{user:user, time:time}));
And translate by JS/JSON i18n sheets, with direct dot-notation reference {} or evaluated expressions ·{}·:
{
user: {
messages: {
logOut: "The user {user.firstName} {user.lastName} has been disconnected at ·{time.toUTCString()}·",
...
},
...
},
...
}
More possible uses (See String.format):
...:"The user ·{username.toUpperCase()}· has been logged out.",
...:"New properties ·{Object.keys(props).join(',')}· added!",
...:"Welcome {user.firstName} {user.lastName}!"
i18n('mail.inbox.status', 5); // Short version
i18n('mail.inbox.status', {_num_:5,...}); // For support of aditional params
Translation entry as array of numeral options:
...:[
"No messages in the inbox",
"There is a message in the inbox",
"There are {_num_} messages in the inbox"
]
"The Object {myObj} is loaded." ==> "The Object {a:'A',b:'B'} is loaded."
"The Array {myArray} is loaded." ==> "The Array ['A','B','C'] is loaded."
// Hypothetical working directory
myApp/
/languages/
/en.js
/es.js
/de.js
/ru.js
i18n.load('nameSpace', './languages');
i18n.languages = ['en', 'es'];
Textualization load from directory ./languages
only i18n.languages
defined, and refresh translations cache if this property changes.
Additionally is possible to use functions in translations sheets.
({
hello: "Hello {name}!",
bye: function (){return "Good bye" + name;}, // contextualized evaluation.
...
})
The brackets at the beginning and end of the statement are optionals. In some text editors allows to have a correct syntax highlighting.
This repository is part of the Pillars.js core libraries. Any contribution, collaboration, issues... is well come ;)
contact Us!:
- Repository issues
- Twitter @pillarsJs
- Mail javi(at)pillarsjs.com
MIT