From 3bfd0a518a3b190593b0fb4a6667e896de3e632b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Thu, 9 Jan 2025 20:42:58 +0100 Subject: [PATCH] Support localizing Android-specific strings Copy `res` folder recursively for Android. Adjust game name in all `strings.xml` files. --- scripts/android/cmake_android.sh | 13 ++++++------- scripts/android/files/build.sh | 4 +++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/android/cmake_android.sh b/scripts/android/cmake_android.sh index a8b7ad0ceac..258c08419fa 100755 --- a/scripts/android/cmake_android.sh +++ b/scripts/android/cmake_android.sh @@ -202,9 +202,6 @@ log_info "Copying project files..." cd "${BUILD_FOLDER}" || exit 1 mkdir -p src/main -mkdir -p src/main/res/values -mkdir -p src/main/res/xml -mkdir -p src/main/res/mipmap function copy_dummy_files() { rm -f ./"$2" @@ -219,10 +216,12 @@ copy_dummy_files scripts/android/files/gradle.properties gradle.properties copy_dummy_files scripts/android/files/proguard-rules.pro proguard-rules.pro copy_dummy_files scripts/android/files/settings.gradle settings.gradle copy_dummy_files scripts/android/files/AndroidManifest.xml src/main/AndroidManifest.xml -copy_dummy_files scripts/android/files/res/values/strings.xml src/main/res/values/strings.xml -copy_dummy_files scripts/android/files/res/xml/shortcuts.xml src/main/res/xml/shortcuts.xml -copy_dummy_files other/icons/DDNet_256x256x32.png src/main/res/mipmap/ic_launcher.png -copy_dummy_files other/icons/DDNet_256x256x32.png src/main/res/mipmap/ic_launcher_round.png + +rm -R -f src/main/res +cp -R ../scripts/android/files/res src/main/ +mkdir -p src/main/res/mipmap +cp ../other/icons/DDNet_256x256x32.png src/main/res/mipmap/ic_launcher.png +cp ../other/icons/DDNet_256x256x32.png src/main/res/mipmap/ic_launcher_round.png log_info "Copying libraries..." diff --git a/scripts/android/files/build.sh b/scripts/android/files/build.sh index 7d0859a495a..115cd9d1f86 100644 --- a/scripts/android/files/build.sh +++ b/scripts/android/files/build.sh @@ -48,7 +48,9 @@ sed -i "s/TW_KEY_ALIAS/${TW_KEY_ALIAS_ESCAPED}/g" build.gradle sed -i "s/TW_VERSION_CODE/${TW_VERSION_CODE}/g" build.gradle sed -i "s/TW_VERSION_NAME/${TW_VERSION_NAME}/g" build.gradle -sed -i "s/DDNet/${APK_BASENAME}/g" src/main/res/values/strings.xml +for f in src/main/res/values*; do + sed -i "s/DDNet/${APK_BASENAME}/g" "$f/strings.xml" +done sed -i "s/org.ddnet.client/${APK_PACKAGE_NAME}/g" src/main/res/xml/shortcuts.xml