txgruppi:simple-i18n

v0.4.1Published 10 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

A simple Meteor internationalization package

Simple internationalization using collections and session.

How to install

  1. Run meteor add txgruppi:simple-i18n

Usage

  1. Run Meteor.I18n() on the server to publish current_language_records.
  2. Run Meteor.I18n() on the client to subscribe to current_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/

More info

http://txgruppi.github.com/meteor-simple-i18n/