forked from recloudstream/cloudstream
add a way to autofix weblate's issue with @string
This commit is contained in:
parent
2d7126d71f
commit
7bfcf25df4
2 changed files with 20 additions and 4 deletions
13
.github/locales.py
vendored
13
.github/locales.py
vendored
|
@ -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"
|
||||
|
@ -46,3 +47,15 @@ open(SETTINGS_PATH, "w+",encoding='utf-8').write(
|
|||
END_MARKER +
|
||||
after_src
|
||||
)
|
||||
|
||||
# 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}")
|
9
.github/workflows/update_locales.yml
vendored
9
.github/workflows/update_locales.yml
vendored
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue