Add ability to download only English string (for developer). This is default behavior.
This commit is contained in:
@@ -20,7 +20,13 @@ In the root folder of the project, run:
|
||||
./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
|
||||
|
||||
|
||||
@@ -18,12 +18,24 @@
|
||||
|
||||
set -e
|
||||
|
||||
echo "Generating the configuration file for localazy..."
|
||||
./tools/localazy/generateLocalazyConfig.py
|
||||
if [[ $1 == "--all" ]]; then
|
||||
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 'translations.xml' -delete
|
||||
|
||||
if [[ $allFiles == 1 ]]; then
|
||||
echo "Deleting all existing translations.xml files..."
|
||||
find . -name 'translations.xml' -delete
|
||||
fi
|
||||
|
||||
echo "Importing the strings..."
|
||||
localazy download --config ./tools/localazy/localazy.json
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
# Read the config.json file
|
||||
with open('./tools/localazy/config.json', 'r') as f:
|
||||
config = json.load(f)
|
||||
|
||||
allFiles = sys.argv[1] == "1"
|
||||
|
||||
# Convert a module name to a path
|
||||
# Ex: ":features:verifysession:impl" => "features/verifysession/impl"
|
||||
@@ -35,20 +37,21 @@ for entry in config["modules"]:
|
||||
"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)
|
||||
allRegexToExcludeFromMainModule.extend(entry["includeRegex"])
|
||||
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
|
||||
mainAction = {
|
||||
@@ -62,16 +65,17 @@ mainAction = {
|
||||
# print(mainAction)
|
||||
allActions.append(mainAction)
|
||||
|
||||
# Append configuration for the main string module: translations
|
||||
mainActionTranslation = {
|
||||
"type": "android",
|
||||
"output": "libraries/ui-strings/src/main/res/values-${langAndroidResNoScript}/translations.xml",
|
||||
"excludeKeys": list(map(lambda i: "REGEX:" + i, allRegexToExcludeFromMainModule + regexToAlwaysExclude)),
|
||||
"conditions": [
|
||||
"!equals: ${languageCode}, en"
|
||||
]
|
||||
}
|
||||
allActions.append(mainActionTranslation)
|
||||
if allFiles:
|
||||
# Append configuration for the main string module: translations
|
||||
mainActionTranslation = {
|
||||
"type": "android",
|
||||
"output": "libraries/ui-strings/src/main/res/values-${langAndroidResNoScript}/translations.xml",
|
||||
"excludeKeys": list(map(lambda i: "REGEX:" + i, allRegexToExcludeFromMainModule + regexToAlwaysExclude)),
|
||||
"conditions": [
|
||||
"!equals: ${languageCode}, en"
|
||||
]
|
||||
}
|
||||
allActions.append(mainActionTranslation)
|
||||
|
||||
# Generate the configuration for localazy
|
||||
result = {
|
||||
|
||||
Reference in New Issue
Block a user