(Bug fix) Fix the weird 'empty translations' & correct backslash escaping in translation strings (#14609)

* (Bug fix) Fix the weird 'empty translations' & correct backslash escaping in translation strings

* Update crowdin workflows
GitHub is deprecating Node.js 12, so some actions need to be updated to ensure functionality into the future.
This commit is contained in:
Michael Burgardt 2022-11-11 07:56:17 +01:00 committed by GitHub
parent a73e1beb1c
commit 648b0ab7b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 10 deletions

View file

@ -16,13 +16,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Setup Java JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 1.8
java-version: 18
distribution: zulu
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Crowdin Sync
shell: bash
env:

View file

@ -18,13 +18,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Setup Java JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 1.8
java-version: 18
distribution: zulu
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Crowdin Sync
shell: bash
env:

View file

@ -88,8 +88,10 @@ def update(messages, template, source_messages):
if tp_msg['key'] in messages and messages[tp_msg['key']] != source_messages[tp_msg['key']]:
tp_msg_val = tp_msg['val']
tl_msg_val = messages[tp_msg['key']]
# escape: reduce \\ -> \ (prevents 'over-expansion': \\ -> \\\\), then expand all \ -> \\
tl_msg_val = tl_msg_val.replace('\\\\', '\\').replace('\\', '\\\\')
# escape all \
tl_msg_val = tl_msg_val.replace('\\', r'\\')
# remove "double-dipping" on escape sequences
tl_msg_val = re.sub(r'\\\\(?=[nrt])', r'\\', tl_msg_val)
# escape other symbols
tl_msg_val = tl_msg_val.replace('"', '\\\"').replace('\n', '')
if tp_msg['key'].find('_QT_') < 0: