From f87c095150219d3b5fbd08b5f2861817f8b3ce74 Mon Sep 17 00:00:00 2001 From: Joe Reeve Date: Tue, 14 Jan 2025 22:28:20 +0000 Subject: [PATCH 1/3] :globe_with_meridians: Start on I18n --- .github/workflows/i18n.yml | 73 ++++++++ .gitignore | 1 + .idea/gradle.xml | 12 ++ app/build.gradle.kts | 9 +- .../co/stonephone/stonecamera/MainActivity.kt | 3 + .../stonephone/stonecamera/StoneCameraApp.kt | 12 +- .../stonecamera/StoneCameraViewModel.kt | 24 ++- .../stonecamera/plugins/AspectRatio.kt | 31 ++-- .../stonephone/stonecamera/plugins/Flash.kt | 29 +-- .../stonephone/stonecamera/plugins/IPlugin.kt | 23 +-- .../stonecamera/plugins/PhotoMode.kt | 3 +- .../stonecamera/plugins/QRScanner.kt | 13 +- .../stonecamera/plugins/SettingsTray.kt | 6 +- .../stonecamera/plugins/ShutterFlash.kt | 1 - .../stonecamera/plugins/VideoMode.kt | 9 +- .../stonecamera/plugins/VolumeControls.kt | 19 +- .../stonecamera/ui/RenderPluginSetting.kt | 14 +- .../stonecamera/utils/TranslatableString.kt | 117 ++++++++++++ app/src/main/res/values-es/strings.xml | 21 +++ app/src/main/res/values-fr/strings.xml | 21 +++ app/src/main/res/values/strings.xml | 24 ++- build.gradle.kts | 13 +- buildSrc/build.gradle.kts | 28 +++ buildSrc/settings.gradle.kts | 13 ++ .../main/kotlin/GenerateTranslationsTask.kt | 167 ++++++++++++++++++ .../src/main/kotlin/UpdateStringsXmlTask.kt | 113 ++++++++++++ gradle.properties | 2 - gradle/libs.versions.toml | 2 + src/main/res/values/strings.xml | 3 + 29 files changed, 726 insertions(+), 80 deletions(-) create mode 100644 .github/workflows/i18n.yml create mode 100644 app/src/main/java/co/stonephone/stonecamera/utils/TranslatableString.kt create mode 100644 app/src/main/res/values-es/strings.xml create mode 100644 app/src/main/res/values-fr/strings.xml create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/settings.gradle.kts create mode 100644 buildSrc/src/main/kotlin/GenerateTranslationsTask.kt create mode 100644 buildSrc/src/main/kotlin/UpdateStringsXmlTask.kt create mode 100644 src/main/res/values/strings.xml diff --git a/.github/workflows/i18n.yml b/.github/workflows/i18n.yml new file mode 100644 index 0000000..a0a0cb9 --- /dev/null +++ b/.github/workflows/i18n.yml @@ -0,0 +1,73 @@ +name: Generate Translations + +on: + push: + branches: + - main + - '**' # just for testing this pr itself + +jobs: + generate-translations: + name: Update and Generate Translations + runs-on: ubuntu-latest + permissions: write-all + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 # Fetch full history for creating PRs + + # Set up JDK + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + with: + gradle-version: wrapper + cache-read-only: false + + # Cache Gradle dependencies + - name: Cache Gradle dependencies + uses: actions/cache@v3 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Update Strings XML + run: ./gradlew updateStringsXml + + - name: Generate Translations + run: ./gradlew generateTranslations + + - name: Check for changes + run: | + if [[ -n "$(git status --porcelain)" ]]; then + echo "Changes detected." + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git checkout -b update-translations + git add . + git commit -m "Update translations" + else + echo "No changes detected." + echo "::set-output name=changes::false" + fi + id: changes-check + + - name: Create Pull Request + if: steps.changes-check.outputs.changes != 'false' + uses: peter-evans/create-pull-request@v5 + with: + branch: update-translations + title: "Update Translations" + body: | + This PR updates the translations by running `./gradlew updateStringsXml` and `./gradlew generateTranslations`. + labels: | + translations diff --git a/.gitignore b/.gitignore index aa724b7..583441d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ .externalNativeBuild .cxx local.properties +buildSrc/build \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 0897082..fcadee0 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,12 +4,24 @@