@abtasty/editor-translations 中文文档教程
Google sheets translations
翻译文件位于此处:https://docs.google.com/spreadsheets/d/13U-j06aW_8FQfhopBrgGHjMNmWjN0UaUaNl5qm12lGg/edit?pli=
1#gid=675474690要运行更新命令,请确保您的节点版本约为 12 和做:
npm run update:translations
Transifex translations
Converting manually the translation files
来自 Transifex 的翻译文件是 GetText 格式,需要转换为 JSON。 有一个 gettext 转换器包 可以做到这一点。
你可以这样使用它:
$ i18next-conv -l en_GB -s abtasty-widgets_en_GB.po -t abtasty-widgets_en_GB.json
Using the translation
我们正在使用 React Intl国际化包。 它将我们的应用程序包装在上下文提供程序中,您可以通过导入访问树中的任何位置。 一个非常简单的用法示例:
intl.formatMessage({id: 'translationKey'});
// OR
useTranslation(translationKey, lang);
Google sheets translations
Translations file is located here: https://docs.google.com/spreadsheets/d/13U-j06aW_8FQfhopBrgGHjMNmWjN0UaUaNl5qm12lGg/edit?pli=1#gid=675474690
To run the update command, please, ensure that your node version is about 12 and do:
npm run update:translations
Transifex translations
Converting manually the translation files
The translation files from Transifex are in a GetText format and need to be converted to JSON. There's a gettext converter package that can do it.
You can use it like so:
$ i18next-conv -l en_GB -s abtasty-widgets_en_GB.po -t abtasty-widgets_en_GB.json
Using the translation
We're using the React Intl package for the internationalisations. It wraps our app in a Context Provider, that you can access anywhere in the tree by importing. A very simple usage example:
intl.formatMessage({id: 'translationKey'});
// OR
useTranslation(translationKey, lang);