Add ability to download only English string (for developer). This is default behavior.
This commit is contained in:
parent
d7a6779343
commit
7bf41d12e2
3 changed files with 49 additions and 27 deletions
|
|
@ -20,7 +20,13 @@ In the root folder of the project, run:
|
||||||
./tools/localazy/downloadStrings.sh
|
./tools/localazy/downloadStrings.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
It will update all the `localazy.xml` and `translations.xml` resource files. In case of merge conflicts, just erase the files and download again using the script.
|
It will update all the `localazy.xml` resource files. In case of merge conflicts, just erase the files and download again using the script.
|
||||||
|
|
||||||
|
To also include the translations, i.e. the `translations.xml` files, add `--all` argument:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./tools/localazy/downloadStrings.sh --all
|
||||||
|
```
|
||||||
|
|
||||||
## Add translations to a specific module
|
## Add translations to a specific module
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,24 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "Generating the configuration file for localazy..."
|
if [[ $1 == "--all" ]]; then
|
||||||
./tools/localazy/generateLocalazyConfig.py
|
echo "Note: I will update all the files."
|
||||||
|
allFiles=1
|
||||||
|
else
|
||||||
|
echo "Note: I will update only the English files."
|
||||||
|
allFiles=0
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Deleting all existing localazy.xml and translations.xml files..."
|
echo "Generating the configuration file for localazy..."
|
||||||
|
./tools/localazy/generateLocalazyConfig.py $allFiles
|
||||||
|
|
||||||
|
echo "Deleting all existing localazy.xml files..."
|
||||||
find . -name 'localazy.xml' -delete
|
find . -name 'localazy.xml' -delete
|
||||||
find . -name 'translations.xml' -delete
|
|
||||||
|
if [[ $allFiles == 1 ]]; then
|
||||||
|
echo "Deleting all existing translations.xml files..."
|
||||||
|
find . -name 'translations.xml' -delete
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Importing the strings..."
|
echo "Importing the strings..."
|
||||||
localazy download --config ./tools/localazy/localazy.json
|
localazy download --config ./tools/localazy/localazy.json
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
# Read the config.json file
|
# Read the config.json file
|
||||||
with open('./tools/localazy/config.json', 'r') as f:
|
with open('./tools/localazy/config.json', 'r') as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
|
|
||||||
|
allFiles = sys.argv[1] == "1"
|
||||||
|
|
||||||
# Convert a module name to a path
|
# Convert a module name to a path
|
||||||
# Ex: ":features:verifysession:impl" => "features/verifysession/impl"
|
# Ex: ":features:verifysession:impl" => "features/verifysession/impl"
|
||||||
|
|
@ -35,20 +37,21 @@ for entry in config["modules"]:
|
||||||
"equals: ${languageCode}, en"
|
"equals: ${languageCode}, en"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
# Create action for the translations
|
|
||||||
actionTranslation = {
|
|
||||||
"type": "android",
|
|
||||||
"output": convertModuleToPath(entry["name"]) + "/src/main/res/values-${langAndroidResNoScript}/translations.xml",
|
|
||||||
"includeKeys": list(map(lambda i: "REGEX:" + i, entry["includeRegex"])),
|
|
||||||
"excludeKeys": list(map(lambda i: "REGEX:" + i, regexToAlwaysExclude)),
|
|
||||||
"conditions": [
|
|
||||||
"!equals: ${languageCode}, en"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
# print(action)
|
# print(action)
|
||||||
allRegexToExcludeFromMainModule.extend(entry["includeRegex"])
|
|
||||||
allActions.append(action)
|
allActions.append(action)
|
||||||
allActions.append(actionTranslation)
|
# Create action for the translations
|
||||||
|
if allFiles:
|
||||||
|
actionTranslation = {
|
||||||
|
"type": "android",
|
||||||
|
"output": convertModuleToPath(entry["name"]) + "/src/main/res/values-${langAndroidResNoScript}/translations.xml",
|
||||||
|
"includeKeys": list(map(lambda i: "REGEX:" + i, entry["includeRegex"])),
|
||||||
|
"excludeKeys": list(map(lambda i: "REGEX:" + i, regexToAlwaysExclude)),
|
||||||
|
"conditions": [
|
||||||
|
"!equals: ${languageCode}, en"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
allActions.append(actionTranslation)
|
||||||
|
allRegexToExcludeFromMainModule.extend(entry["includeRegex"])
|
||||||
|
|
||||||
# Append configuration for the main string module: default language
|
# Append configuration for the main string module: default language
|
||||||
mainAction = {
|
mainAction = {
|
||||||
|
|
@ -62,16 +65,17 @@ mainAction = {
|
||||||
# print(mainAction)
|
# print(mainAction)
|
||||||
allActions.append(mainAction)
|
allActions.append(mainAction)
|
||||||
|
|
||||||
# Append configuration for the main string module: translations
|
if allFiles:
|
||||||
mainActionTranslation = {
|
# Append configuration for the main string module: translations
|
||||||
"type": "android",
|
mainActionTranslation = {
|
||||||
"output": "libraries/ui-strings/src/main/res/values-${langAndroidResNoScript}/translations.xml",
|
"type": "android",
|
||||||
"excludeKeys": list(map(lambda i: "REGEX:" + i, allRegexToExcludeFromMainModule + regexToAlwaysExclude)),
|
"output": "libraries/ui-strings/src/main/res/values-${langAndroidResNoScript}/translations.xml",
|
||||||
"conditions": [
|
"excludeKeys": list(map(lambda i: "REGEX:" + i, allRegexToExcludeFromMainModule + regexToAlwaysExclude)),
|
||||||
"!equals: ${languageCode}, en"
|
"conditions": [
|
||||||
]
|
"!equals: ${languageCode}, en"
|
||||||
}
|
]
|
||||||
allActions.append(mainActionTranslation)
|
}
|
||||||
|
allActions.append(mainActionTranslation)
|
||||||
|
|
||||||
# Generate the configuration for localazy
|
# Generate the configuration for localazy
|
||||||
result = {
|
result = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue