From 2c1a2dc444980338c8ab1ec72bcf3aa0a0509e28 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 5 Jan 2023 16:57:53 +0100 Subject: [PATCH] Add script to import strings, and doc. Add GitHub action to sync strings. --- .../workflows/sync-from-external-sources.yml | 25 ++++++++ libraries/ui-strings/README.md | 15 +++++ tools/strings/importStringsFromElement.sh | 57 +++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 .github/workflows/sync-from-external-sources.yml create mode 100644 libraries/ui-strings/README.md create mode 100755 tools/strings/importStringsFromElement.sh diff --git a/.github/workflows/sync-from-external-sources.yml b/.github/workflows/sync-from-external-sources.yml new file mode 100644 index 0000000000..c9c8528904 --- /dev/null +++ b/.github/workflows/sync-from-external-sources.yml @@ -0,0 +1,25 @@ +name: Sync Data From External Sources +on: + schedule: + # Every nights at 6 + - cron: "0 6 * * *" + +jobs: + sync-strings: + runs-on: ubuntu-latest + # Skip in forks + if: github.repository == 'vector-im/element-x-android' + # No concurrency required, runs every time on a schedule. + steps: + - uses: actions/checkout@v3 + - name: Run local script + run: ./tools/strings/importStringsFromElement.sh + - name: Create Pull Request + uses: peter-evans/create-pull-request@v4 + with: + commit-message: Import strings from Element Android + title: Sync strings + body: | + - Update strings from Element Android + branch: sync-strings + base: develop diff --git a/libraries/ui-strings/README.md b/libraries/ui-strings/README.md new file mode 100644 index 0000000000..bb55709240 --- /dev/null +++ b/libraries/ui-strings/README.md @@ -0,0 +1,15 @@ +## Module ui-strings + +This module contains strings from Element Android. + +The content of this module will be keep synced by the script `rootDir/tools/strings/importStringsFromElement.sh`, which is run daily by a GitHub action. + +### Adding new strings + +Add new strings to the file `./src/main/res/values/new_strings.xml`, or your new strings will be erased on the next sync. + +Also, new strings must be added to Element Android to give a chance to get translation. + +### Long term + +In the future, Weblate will be synced directly with this project. diff --git a/tools/strings/importStringsFromElement.sh b/tools/strings/importStringsFromElement.sh new file mode 100755 index 0000000000..b17adf06a5 --- /dev/null +++ b/tools/strings/importStringsFromElement.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +# +# Copyright (c) 2023 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +printf "\n" +printf "================================================================================\n" +printf "| Importing strings from Element |\n" +printf "================================================================================\n" + +basedir=`pwd` +tmpPath="${basedir}/tmpStrings" + +## Delete tmp dir +#rm -rf ${tmpPath} + +# Create tmp dir +mkdir ${tmpPath} + +printf "\n================================================================================\n" +printf "Downloading Element Android source from develop...\n" + +curl https://github.com/vector-im/element-android/archive/refs/heads/develop.zip -i -L -o ${tmpPath}/element.zip + +printf "\n================================================================================\n" +printf "Unzipping Element Android source...\n" + +unzip -q ${tmpPath}/element.zip -d ${tmpPath} + +printf "\n================================================================================\n" +printf "Importing the strings...\n" +elementAndroidPath="${tmpPath}/element-android-develop" + +cp -R ${elementAndroidPath}/library/ui-strings/src/main/res ${basedir}/libraries/ui-strings/src/main + +## Delete tmp dir +rm -rf ${tmpPath} + +# Commit all changes to git +# git commit -a -m "Import strings from Element Android" + +printf "\n================================================================================\n" +printf "Done\n" +printf "================================================================================\n"