Skip to content

Commit 685591f

Browse files
authored
[l10n] Enable lingui, string extraction (#810)
* l10n: add lingui, configure, update .babelrc, add gettext:extract & gettext:compile tasks pretty much just adds default lingui config and deps * run gettext:extract - added a t`` to a single string, ran extract, added .po to prettierignore * run gettext:compile - translate single string, compile, add code to activate the translation * l10n.ts: list available locales, use navigator.languages to pick, default to en * more l10n - plural & t get_human_size - use plural correctly for the number of bytes czech translation should have 3 plurals, english 2 paths - use t`` now +extract, clean old string, translate, compile * Replace _`str` with t`str` perl -i -npe 's/\b_\`/t\`/g' src/** * Remove window._ temporary l10n global * import { t } everywhere where used rg '\bt`' | cut -f1 -d: | sort -u | while read fn; do (echo '0a'; echo 'import { t } from '\''@lingui/macro'\'';'; echo '.'; echo 'wq') | ed "$fn"; done * tsconfig - set module 2020 to allow dynamic imports src/l10n.ts:13:30 - error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. 13 const { messages } = await import(`src/../locale/${locale}.js`); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Fix trailing spaces in translations extraction trims trailing whitespace detect: rg \\bt'`'.*' `' fixed all of them by adding params inside, or adding and extra `{' '}` react bit * entry*: add I18nProvider around App needed for Trans * src/ use Trans where appropriate * get better param names when using vars * gettext:extract * cs.po: manual fixup bytes example * update list of languages to en,es,fr,nl,ja,zh, regenerate
1 parent 727b962 commit 685591f

File tree

96 files changed

+13422
-648
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+13422
-648
lines changed

.babelrc

+1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
"@babel/plugin-syntax-dynamic-import",
99
"@babel/plugin-transform-runtime",
1010
"babel-plugin-lodash",
11+
"babel-plugin-macros",
1112
]
1213
}

.linguirc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"catalogs": [{
3+
"path": "<rootDir>/locale/{locale}",
4+
"include": ["<rootDir>/src"]
5+
}],
6+
"format": "po",
7+
"locales": ["en", "es", "fr", "nl", "ja", "zh"],
8+
"sourceLocale": "en"
9+
}

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ Dockerfile
88
*.md
99
*.png
1010
*.mp4
11+
*.po

locale/en.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)