diff --git a/.github/locales.py b/.github/locales.py index 1c79c093..04d9cd13 100644 --- a/.github/locales.py +++ b/.github/locales.py @@ -1,6 +1,7 @@ import re import glob import requests +import lxml.etree as ET # builtin library doesn't preserve comments SETTINGS_PATH = "app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsGeneral.kt" @@ -45,4 +46,16 @@ open(SETTINGS_PATH, "w+",encoding='utf-8').write( "\n" + END_MARKER + after_src -) \ No newline at end of file +) + +# Go through each values.xml file and fix escaped \@string +for file in glob.glob(f"{XML_NAME}*/strings.xml"): + try: + tree = ET.parse(file) + for child in tree.getroot(): + if child.text.startswith("\\@string/"): + print(f"[{file}] fixing {child.attrib['name']}") + child.text = child.text.replace("\\@string/", "@string/") + tree.write(file, encoding="utf-8", method="xml", pretty_print=True, xml_declaration=True) + except ET.ParseError as ex: + print(f"[{file}] {ex}") \ No newline at end of file diff --git a/.github/workflows/update_locales.yml b/.github/workflows/update_locales.yml index 93cdca44..628e9bc9 100644 --- a/.github/workflows/update_locales.yml +++ b/.github/workflows/update_locales.yml @@ -1,4 +1,4 @@ -name: Update locale lists +name: Fix locale issues on: workflow_dispatch: @@ -9,7 +9,7 @@ on: - master concurrency: - group: "locale-list" + group: "locale" cancel-in-progress: true jobs: @@ -26,6 +26,9 @@ jobs: - uses: actions/checkout@v2 with: token: ${{ steps.generate_token.outputs.token }} + - name: Install dependencies + run: | + pip3 install lxml - name: Edit files run: | python3 .github/locales.py @@ -35,5 +38,5 @@ jobs: git config --local user.name "recloudstream[bot]" git add . # "echo" returns true so the build succeeds, even if no changed files - git commit -m 'update list of locales' || echo + git commit -m 'chore(locales): fix locale issues' || echo git push