From 648b0ab7b7f8a63fc302f22be11c024fcdf6b998 Mon Sep 17 00:00:00 2001 From: Michael Burgardt Date: Fri, 11 Nov 2022 07:56:17 +0100 Subject: [PATCH] (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. --- .github/workflows/crowdin-daily.yml | 11 +++++++---- .github/workflows/crowdin.yml | 11 +++++++---- intl/json2h.py | 6 ++++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.github/workflows/crowdin-daily.yml b/.github/workflows/crowdin-daily.yml index 582049a42f..cb2eb994e2 100644 --- a/.github/workflows/crowdin-daily.yml +++ b/.github/workflows/crowdin-daily.yml @@ -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: diff --git a/.github/workflows/crowdin.yml b/.github/workflows/crowdin.yml index 9aa97e3bc5..2e1079528d 100644 --- a/.github/workflows/crowdin.yml +++ b/.github/workflows/crowdin.yml @@ -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: diff --git a/intl/json2h.py b/intl/json2h.py index ccbe4aa489..a7007bc7ba 100755 --- a/intl/json2h.py +++ b/intl/json2h.py @@ -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: