【发布时间】:2016-11-27 11:12:03
【问题描述】:
我研究流星例如https://github.com/meteor/simple-todos-react 我正在尝试添加多语言支持。 我创建了翻译文件。
在文件/imports/ui/App.jsx我添加了代码:
import i18n from 'meteor/universe:i18n';
i18n.setLocale('en-US');
const T = i18n.createComponent();
i18n.setLocale('en-US').then(function () {
console.log('hello');
});
在渲染方法中我添加了:
. . . .
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>
. . . .
文件en-US.i18n.json
{ "hello": "hello world!" }
但不幸的是,我没有找到文本并没有被翻译成很好的例子。 我做错了什么?
【问题讨论】:
-
不应该将该文件称为 en-US 即使用连字符而不是使用下划线吗?
-
好的,我正在更新,但它没有改变任何东西。
-
hello之后有一个额外的空格 - 这可能是原因。 -
您发现问题了吗?
标签: javascript reactjs meteor internationalization