Any examples: i18n with Meteor/Blaze & React

I’m looking for examples of using i18n with Meteor/Blaze and Meteor/React. Will someone point me to a repo with example code?

Also, this is the lib I think I’m going to use:

Here’s my question on the github page with examples of what I’m trying to Localize.

Config:

const i18nConfig = {
  settings: {
    defaultLocale: "en",
    ru: {
      code: "ru",
      isoCode: "ru-RU",
      name: "Русский"
    },
    en: {
      code: "en",
      isoCode: "en-US",
      name: "English"
    }
  },
  ru: {
    property: "значение",
  },
  en: {
    property: "value"
  }
};

Initialize:

import I18N from 'meteor/ostrio:i18n';
const i18n = new I18N({i18n: i18nConfig});

React:

i18n.setLocale('en');
i18n.get('property'); // -> value

i18n.setLocale('ru');
i18n.get('property'); // -> значение

You can use same in a Blaze helpers, or use TemplateHelper i18n:

<p>{{i18n 'property'}}</p> <!-- value -->
1 Like

Thanks @dr.dimitru!

This solution works as well nicely! It’s great to know their’s still great solutions for Localizing your application in Meteor 1.8!

1 Like