CityWebConsultants / Iris

Modular content management and web application framework built with Node.js and MongoDB
http://irisjs.org
Other
9 stars 7 forks source link

Integrate i18n into Iris #111

Closed adam-clarey closed 8 years ago

adam-clarey commented 8 years ago

A new library has been added as a dependency, so npm install (or npm update?) will be required.

To test, in your code where ever authPass is available:

var string = req/thisHook.authPass.t('My string');

string should = 'My string'

The language defaults to en, so check in /configurations/locals for a file en.js

This should contain something like {'My string' : 'My string'}

To test translating from one language to another, create a de.js file in /locals and add:

{
    "My string": "German string"
}

Then in your function do:

var ap = thisHook.authPass;
// Change the language for this user. This would typically be done in hook_auth_authpass
ap.setLocale('de');

var string = ap.t('My string');

string should now = 'German string'

For more info on how to do more complicated translations, consult https://github.com/mashpie/i18n-node