1
私の流星群の翻訳にはuniverse:i18n
を使っています(反応を使って)。反応成分の配列要素のためのi18n
輸入/ UI /コンポーネント/ example.jsx
:私はmap()
を使用して配列を反復処理し、出力として、私は翻訳などのカテゴリを取得したいと思いあなたが見ることができます。このコンポーネントでは、
import React, { Component } from 'react'
import i18n from 'meteor/universe:i18n'
class Example extends Component {
getCategories(index) {
const categories = [ 'one', 'two', 'three' ]; // <-- Get correct translations of these elements
return categories[index - 1];
}
render() {
return (
<div id="content">
{ this.props.sections.map((i) => {
return (
<div>
{ this.getCategories(i.index) }
</div>
);
}) }
</div>
);
}
}
I18N/de.i18.json
{
categories: {
one: 'Eins',
two: 'Zwei',
three: 'Drei'
}
}
私はあなたの代わりにbracker表記のドットを使用する必要があるため、それは動作しません
const T = i18n.createComponent()
class Example extends Component {
getCategories(index) {
const categories = [ 'one', 'two', 'three' ]; // <-- Get correct translations of these elements
return categories[index - 1];
}
render() {
return (
<div id="content">
{ this.props.sections.map((i) => {
return (
<div>
<T>categories[{ this.getCategories(i.index) }]</T>
</div>
);
}) }
</div>
);
}
}