A simple Meteor internationalization package
Simple internationalization using collections and session.
How to install
- Run
meteor add txgruppi:simple-i18n
Usage
- Run
Meteor.I18n()
on the server to publishcurrent_language_records
. - Run
Meteor.I18n()
on the client to subscribe tocurrent_language_records
.
You can pass some options to initialize the i18n package, see I18n.prototype.init
for more info
How to add translations
Do something like this (server side):
1var translations = [ 2 {lang: 'pt-br', base_str: 'Hello', new_str: 'Olá'}, 3 {lang: 'de', base_str: 'Hello', new_str: 'Hallo'}, 4 {lang: 'es', base_str: 'Hello', new_str: 'Hola'}, 5 {lang: 'it', base_str: 'Hello', new_str: 'Ciao'} 6]; 7var i18n = Meteor.I18n(); 8 9for (var i in translations) { 10 if (!i18n.collection.findOne({lang: translations[i].lang, base_str: translations[i].base_str})) { 11 i18n.insert(translations[i].lang, translations[i].base_str, translations[i].new_str); 12 } 13}
Sample here!
http://simple-i18n-sample.meteor.com/