Skip to content

Instantly share code, notes, and snippets.

@ThaddeusJiang
Created August 27, 2018 06:37
Show Gist options
  • Save ThaddeusJiang/d6b989c3c9b74fa7f55c7c970dd55ce4 to your computer and use it in GitHub Desktop.
Save ThaddeusJiang/d6b989c3c9b74fa7f55c7c970dd55ce4 to your computer and use it in GitHub Desktop.
React i18n

相关文件

  1. i18nHelper.js 封装
  2. ja.js en.js zh.js 翻译
  3. component.js 实际使用位置

示例

  1. src/huckleberry/src/locales/i18nHelper.js
+  tag: {
+    id: 'cms.message.tag',
+    defaultMessage: 'タグ',
+  },
  1. ja.js, en.js, zh.js
+  'cms.message.tag': 'タグ',
  1. component
+ import { I18nElement, messages } from '../../locales/i18nHelper'
- 'タグ'
+ <I18nElement {...messages.tag} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment