From a4207d9bc9266bf53b7c4832ff8586aca1fc3013 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 29 Feb 2024 09:45:42 +0100 Subject: [PATCH 1/3] Do not redirect output of commands to /dev/null. --- tools/localazy/downloadStrings.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/localazy/downloadStrings.sh b/tools/localazy/downloadStrings.sh index e7dd6d687b..71f103c801 100755 --- a/tools/localazy/downloadStrings.sh +++ b/tools/localazy/downloadStrings.sh @@ -41,17 +41,17 @@ echo "Importing the strings..." localazy download --config ./tools/localazy/localazy.json echo "Formatting the resources files..." -find . -name 'localazy.xml' -exec ./tools/localazy/formatXmlResourcesFile.py {} \; >> /dev/null +find . -name 'localazy.xml' -exec ./tools/localazy/formatXmlResourcesFile.py {} \; if [[ $allFiles == 1 ]]; then - find . -name 'translations.xml' -exec ./tools/localazy/formatXmlResourcesFile.py {} \; >> /dev/null + find . -name 'translations.xml' -exec ./tools/localazy/formatXmlResourcesFile.py {} \; fi set +e echo "Moving files from values-id to values-in..." -find . -type d -name 'values-id' -execdir mv {}/translations.xml {}/../values-in/translations.xml 2> /dev/null \; +find . -type d -name 'values-id' -execdir mv {}/translations.xml {}/../values-in/translations.xml \; echo "Deleting all the folders values-id..." -find . -type d -name 'values-id' -exec rm -rf {} 2> /dev/null \; +find . -type d -name 'values-id' -exec rm -rf {} \; set -e echo "Removing the generated config" From b921991b1a4f06f412351f16173c4fa36bc382ad Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 29 Feb 2024 09:58:55 +0100 Subject: [PATCH 2/3] Format XML resource: ignore empty Node (which is different than empty String). --- tools/localazy/formatXmlResourcesFile.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tools/localazy/formatXmlResourcesFile.py b/tools/localazy/formatXmlResourcesFile.py index 3e0326cf9d..41bfc17b24 100755 --- a/tools/localazy/formatXmlResourcesFile.py +++ b/tools/localazy/formatXmlResourcesFile.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 -import sys import re +import sys from xml.dom import minidom file = sys.argv[1] @@ -19,8 +19,14 @@ resource = dict() ### Strings for elem in content.getElementsByTagName('string'): name = elem.attributes['name'].value - value = elem.firstChild.nodeValue # Continue if value is empty + child = elem.firstChild + if child is None: + # Print an error to stderr + print('Warning: Empty content for string: ' + name + " in file " + file, file=sys.stderr) + continue + value = child.nodeValue + # Continue if string is empty if value == '""': # Print an error to stderr print('Warning: Empty string value for string: ' + name + " in file " + file, file=sys.stderr) @@ -35,11 +41,17 @@ for elem in content.getElementsByTagName('plurals'): for it in elem.childNodes: if it.nodeType != it.ELEMENT_NODE: continue - value = it.firstChild.nodeValue # Continue if value is empty + child = it.firstChild + if child is None: + # Print an error to stderr + print('Warning: Empty content for plurals: ' + name + " in file " + file, file=sys.stderr) + continue + value = child.nodeValue + # Continue if string is empty if value == '""': # Print an error to stderr - print('Warning: Empty item value for plural: ' + name + " in file " + file, file=sys.stderr) + print('Warning: Empty item value for plurals: ' + name + " in file " + file, file=sys.stderr) continue plural.appendChild(it.cloneNode(True)) if plural.hasChildNodes(): @@ -59,7 +71,7 @@ result = re.sub(r" ([\?\!\:…])", r" \1", result) # Special treatment for French wording if 'values-fr' in file: ## Replace ' with ’ - result = re.sub(r"([cdjlmnsu])\\\'", r"\1’", result, flags = re.IGNORECASE) + result = re.sub(r"([cdjlmnsu])\\\'", r"\1’", result, flags=re.IGNORECASE) with open(file, "w") as text_file: text_file.write(result) From 2c010c0f14d3217e9a7f08a8a336d750bfcb7a93 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 29 Feb 2024 10:00:47 +0100 Subject: [PATCH 3/3] A gradle task will be run now, so we need Java 17 and gradle setup. --- .github/workflows/sync-localazy.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/sync-localazy.yml b/.github/workflows/sync-localazy.yml index 035d44eba9..50ebc12c95 100644 --- a/.github/workflows/sync-localazy.yml +++ b/.github/workflows/sync-localazy.yml @@ -12,6 +12,15 @@ jobs: if: github.repository == 'element-hq/element-x-android' steps: - uses: actions/checkout@v4 + - name: Use JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' # See 'Supported distributions' for available options + java-version: '17' + - name: Configure gradle + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: ${{ github.ref != 'refs/heads/develop' }} - name: Set up Python 3.9 uses: actions/setup-python@v5 with: