-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
i18n: reorg files, api key check, formatting scripts, documenting rea…
…sons why...
- Loading branch information
1 parent
4fe0834
commit 402bebb
Showing
23 changed files
with
1,590 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
LANGS="de_DE zh_CN es_ES fr_FR ru_RU it_IT ja_JP pt_PT ko_KR pl_PL tr_TR he_IL" | ||
|
||
check_api_key() { | ||
if [ -z "${SIMPLELOCALIZE_KEY}" ]; then | ||
echo "Error: SIMPLELOCALIZE_KEY is not set or is empty. Please provide a valid API key." >&2 | ||
exit 1 | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
#!/usr/bin/env bash | ||
. ./i18n/bin/common.sh | ||
|
||
# It was necessary to write a custom formatter (see formatter.js) – not clear why, but it works. It's just a trivial mapping. | ||
# "--ast" this is the main point of compiling: we use ICU messages, which no longer need to be parsed each time. | ||
# This compile step is called by the `pnpm build` step as well, hence there is no need to keep the compiled files in the sources. | ||
for L in $LANGS; do | ||
pnpm exec formatjs compile --ast --format i18n/formatter.js --out-file ./i18n/$L.compiled.json ./i18n/$L.json | ||
#rm ./i18n/$L.json # we might want to delete it at some point, but for now it is nice to have a copy of the translated messages | ||
pnpm exec formatjs compile \ | ||
--ast \ | ||
--format i18n/formatter.js \ | ||
--out-file ./i18n/trans/$L.compiled.json \ | ||
./i18n/trans/$L.json | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
#!/usr/bin/env bash | ||
. ./i18n/bin/common.sh | ||
|
||
check_api_key | ||
|
||
# Each language is downloaded into a spearate file and compiled – this allows for dynamic imports. | ||
for L in $LANGS; do | ||
simplelocalize download --apiKey $SIMPLELOCALIZE_KEY --downloadPath ./i18n/$L.json --downloadFormat single-language-json --languageKey=$L | ||
simplelocalize download \ | ||
--apiKey $SIMPLELOCALIZE_KEY \ | ||
--downloadPath ./i18n/trans/$L.json \ | ||
--downloadFormat single-language-json \ | ||
--languageKey=$L | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
pnpm exec formatjs extract $(git ls-files '**/*.tsx') i18n/*.ts jupyter/commands.ts \ | ||
--ignore='**/*.d.ts' --ignore='node_modules/*' \ | ||
--ignore='dist/*' \ | ||
--out-file i18n/extracted.json \ | ||
--throws \ | ||
--id-interpolation-pattern 'UNIQUE_ID_IS_MISSING' | ||
# The interpolation pattern is a fixed string, because we intentionally trigger ID colissions. | ||
# There is just one (unused) string without a unique ID – otherwise we always set an explicit hierarchical ID. | ||
# Read the README in this directory for more information. | ||
pnpm exec formatjs extract $(git ls-files '**/*.tsx') i18n/*.ts jupyter/commands.ts \ | ||
--ignore='**/*.d.ts' --ignore='node_modules/*' \ | ||
--ignore='dist/*' \ | ||
--out-file i18n/extracted.json \ | ||
--throws \ | ||
--id-interpolation-pattern 'UNIQUE_ID_IS_MISSING' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
simplelocalize upload --apiKey $SIMPLELOCALIZE_KEY --languageKey en --uploadFormat simplelocalize-json --overwrite --uploadPath ./i18n/extracted.json | ||
. ./i18n/bin/common.sh | ||
check_api_key | ||
|
||
# The English language is always used directly from the default strings. | ||
# During upload, any changes are overwritten as well. | ||
simplelocalize upload \ | ||
--apiKey $SIMPLELOCALIZE_KEY \ | ||
--languageKey en \ | ||
--uploadFormat simplelocalize-json \ | ||
--overwrite \ | ||
--uploadPath ./i18n/extracted.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.