Example for universe-i18n and react-todos together

I began to study the meteor for example GitHub - meteor/simple-todos-react: A repository that follows the React tutorial step-by-step
And I’m trying to add multilingual support.
I created file translated.

In the file /imports/ui/App.jsx I added code:

import i18n from 'meteor/universe:i18n';

i18n.setLocale('en-US');

const T = i18n.createComponent();

i18n.setLocale('en-US').then(function () {
    console.log('hello');
});

And in render method I added:

 . . . . 
  render() {
    return (
      <div className="container">
        <header>
          <h1>Todo List ({this.props.incompleteCount})</h1>
          <T>hello </T>
          <T _locale='ru-RU'>hello </T>
          <T tagType='h1'>hello </T>
  . . . .

file en-US.i18n.json
{ "hello": "hello world!" }
But the text is not translated as good examples unfortunately I have not found.
What am I doing wrong?

I had the same problem and I noticed that you should put your lang files outside imports directory. For example you can put your files in root.

Example

/both/i18n/en-US.i18n.json

or

/i18n/en-US.i18n.json

If you wont to put translation files in imports directory you should compile them to JS

1 Like