Implement automatic-per-app-languages #5649
Signed-off-by: Nima <74507096+Nimausfi@users.noreply.github.com>
This commit is contained in:
parent
437dac3d5f
commit
e0024b38ef
6 changed files with 4 additions and 83 deletions
|
@ -64,7 +64,6 @@
|
|||
android:dataExtractionRules="@xml/backup_content_v31"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:localeConfig="@xml/locales_config"
|
||||
android:theme="@style/MwmTheme"
|
||||
android:supportsRtl="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
|
|
|
@ -159,7 +159,6 @@ android {
|
|||
buildConfigField 'String', 'SUPPORT_MAIL', '"android@organicmaps.app"'
|
||||
// Should be customized in flavors.
|
||||
buildConfigField 'String', 'REVIEW_URL', '""'
|
||||
resourceConfigurations += [project.ext.supportedLocalizations]
|
||||
|
||||
multiDexEnabled true
|
||||
multiDexKeepFile file('multidex-config.txt')
|
||||
|
@ -408,6 +407,9 @@ android {
|
|||
androidResources {
|
||||
ignoreAssetsPattern '!.svn:!.git:!.DS_Store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~'
|
||||
noCompress 'txt', 'bin', 'html', 'png', 'json', 'mwm', 'ttf', 'sdf', 'ui', 'config', 'csv', 'spv', 'obj'
|
||||
|
||||
// Turn automatic per-app language feature on
|
||||
generateLocaleConfig true
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
|
|
|
@ -11,5 +11,3 @@ android.defaults.buildfeatures.buildconfig=true
|
|||
android.nonTransitiveRClass=false
|
||||
android.nonFinalResIds=false
|
||||
|
||||
# Autogenerated by tools/unix/generate_localizations.sh
|
||||
supportedLocalizations=af,ar,be,bg,ca,cs,da,de,el,en,en_GB,es,es_MX,et,eu,fa,fi,fr,fr_CA,iw,hi,hu,in,it,ja,ko,lt,mr,nb,nl,pl,pt,pt_BR,ro,ru,sk,sv,sw,th,tr,uk,vi,zh,zh_HK,zh_MO,zh_TW
|
||||
|
|
1
android/res/resources.properties
Normal file
1
android/res/resources.properties
Normal file
|
@ -0,0 +1 @@
|
|||
unqualifiedResLocale=en-US
|
|
@ -1,49 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<locale android:name="en" />
|
||||
<locale android:name="af" />
|
||||
<locale android:name="ar" />
|
||||
<locale android:name="be" />
|
||||
<locale android:name="bg" />
|
||||
<locale android:name="ca" />
|
||||
<locale android:name="cs" />
|
||||
<locale android:name="da" />
|
||||
<locale android:name="de" />
|
||||
<locale android:name="el" />
|
||||
<locale android:name="en-GB" />
|
||||
<locale android:name="es" />
|
||||
<locale android:name="es-MX" />
|
||||
<locale android:name="et" />
|
||||
<locale android:name="eu" />
|
||||
<locale android:name="fa" />
|
||||
<locale android:name="fi" />
|
||||
<locale android:name="fr" />
|
||||
<locale android:name="fr-CA" />
|
||||
<locale android:name="iw" />
|
||||
<locale android:name="hi" />
|
||||
<locale android:name="hu" />
|
||||
<locale android:name="in" />
|
||||
<locale android:name="it" />
|
||||
<locale android:name="ja" />
|
||||
<locale android:name="ko" />
|
||||
<locale android:name="lt" />
|
||||
<locale android:name="mr" />
|
||||
<locale android:name="nb" />
|
||||
<locale android:name="nl" />
|
||||
<locale android:name="pl" />
|
||||
<locale android:name="pt" />
|
||||
<locale android:name="pt-BR" />
|
||||
<locale android:name="ro" />
|
||||
<locale android:name="ru" />
|
||||
<locale android:name="sk" />
|
||||
<locale android:name="sv" />
|
||||
<locale android:name="sw" />
|
||||
<locale android:name="th" />
|
||||
<locale android:name="tr" />
|
||||
<locale android:name="uk" />
|
||||
<locale android:name="vi" />
|
||||
<locale android:name="zh" />
|
||||
<locale android:name="zh-HK" />
|
||||
<locale android:name="zh-MO" />
|
||||
<locale android:name="zh-TW" />
|
||||
</locale-config>
|
|
@ -67,33 +67,3 @@ cat "$STRINGS_PATH"/{strings,types_strings}.txt> "$MERGED_FILE"
|
|||
"$TWINE" generate-all-localization-files --format jquery "$OMIM_PATH/data/strings/sound.txt" "$OMIM_PATH/data/sound-strings/"
|
||||
|
||||
rm "$MERGED_FILE"
|
||||
|
||||
# Generate list of languages and add list in gradle.properties to be used in build.gradle in resConfig
|
||||
SUPPORTED_LOCALIZATIONS="supportedLocalizations="$(sed -nEe "s/ +([a-zA-Z]{2}(-[a-zA-Z]{2,})?) = .*$/\1/p" "data/strings/strings.txt" | sort -u | tr '\n' ',' | sed -e 's/-/_/g' -e 's/,$//')
|
||||
# Chinese locales should correspond to Android codes.
|
||||
SUPPORTED_LOCALIZATIONS=${SUPPORTED_LOCALIZATIONS/zh_Hans/zh}
|
||||
SUPPORTED_LOCALIZATIONS=${SUPPORTED_LOCALIZATIONS/zh_Hant/zh_HK,zh_MO,zh_TW}
|
||||
SUPPORTED_LOCALIZATIONS=${SUPPORTED_LOCALIZATIONS/he/iw}
|
||||
SUPPORTED_LOCALIZATIONS=${SUPPORTED_LOCALIZATIONS/id/in}
|
||||
GRADLE_PROPERTIES="$OMIM_PATH/android/gradle.properties"
|
||||
if [ "$SUPPORTED_LOCALIZATIONS" != "$(grep supportedLocalizations "$GRADLE_PROPERTIES")" ]; then
|
||||
sed -i .bak 's/supportedLocalizations.*/'"$SUPPORTED_LOCALIZATIONS"'/' "$GRADLE_PROPERTIES"
|
||||
rm "$GRADLE_PROPERTIES.bak"
|
||||
fi
|
||||
|
||||
# Generate locales_config.xml to allow users change app's language on Android 13+
|
||||
LOCALES_CONFIG="$OMIM_PATH/android/res/xml/locales_config.xml"
|
||||
SUPPORTED_LOCALIZATIONS=${SUPPORTED_LOCALIZATIONS/supportedLocalizations=/en,}
|
||||
SUPPORTED_LOCALIZATIONS=${SUPPORTED_LOCALIZATIONS/,en,/,}
|
||||
SUPPORTED_LOCALIZATIONS=${SUPPORTED_LOCALIZATIONS//_/-}
|
||||
LOCALES_CONTENT='<?xml version="1.0" encoding="utf-8"?>
|
||||
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">'
|
||||
set +x
|
||||
for lang in ${SUPPORTED_LOCALIZATIONS//,/ }; do
|
||||
LOCALES_CONTENT="$LOCALES_CONTENT"$'\n'" <locale android:name=\"$lang\" />"
|
||||
done
|
||||
LOCALES_CONTENT="$LOCALES_CONTENT"$'\n''</locale-config>'
|
||||
if [ "$LOCALES_CONTENT" != "$(cat "$LOCALES_CONFIG")" ]; then
|
||||
echo "$LOCALES_CONTENT" > "$LOCALES_CONFIG"
|
||||
echo Updated "$LOCALES_CONFIG" file
|
||||
fi
|
||||
|
|
Reference in a new issue