From 88e8663d4449dedbadd84bc95fc5be6f40707a3d Mon Sep 17 00:00:00 2001 From: Ludy Date: Wed, 26 Jun 2024 22:47:20 +0200 Subject: [PATCH] Rename from translation_status.toml to ignore_translation.toml and more (#1511) --- .github/workflows/sync_files.yml | 14 +-- .pre-commit-config.yaml | 8 +- README.md | 2 +- Version-groups.md | 2 +- scripts/counter_translation.py | 95 +++++++++------ scripts/ignore_translation.toml | 203 +++++++++++++++++++++++++++++-- scripts/translation_status.toml | 183 ---------------------------- 7 files changed, 265 insertions(+), 242 deletions(-) delete mode 100644 scripts/translation_status.toml diff --git a/.github/workflows/sync_files.yml b/.github/workflows/sync_files.yml index ac1556cd..c9365460 100644 --- a/.github/workflows/sync_files.yml +++ b/.github/workflows/sync_files.yml @@ -7,7 +7,7 @@ on: paths: - "build.gradle" - "src/main/resources/messages_*.properties" - - "scripts/translation_status.toml" + - "scripts/ignore_translation.toml" permissions: contents: write @@ -17,9 +17,9 @@ jobs: sync-versions: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v5.1.0 + uses: actions/setup-python@v5 with: python-version: "3.x" - name: Install dependencies @@ -36,7 +36,7 @@ jobs: git diff --staged --quiet || git commit -m ":floppy_disk: Sync Versions > Made via sync_files.yml" || echo "no changes" - name: Create Pull Request - uses: peter-evans/create-pull-request@v6.0.1 + uses: peter-evans/create-pull-request@v6 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: Update files @@ -54,9 +54,9 @@ jobs: sync-readme: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v5.1.0 + uses: actions/setup-python@v5 with: python-version: "3.x" - name: Install dependencies @@ -73,7 +73,7 @@ jobs: git diff --staged --quiet || git commit -m ":memo: Sync README > Made via sync_files.yml" || echo "no changes" - name: Create Pull Request - uses: peter-evans/create-pull-request@v6.0.1 + uses: peter-evans/create-pull-request@v6 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: Update files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e397fc5d..45ce3639 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,9 +6,11 @@ repos: args: - --fix - --line-length=127 - files: ^((.github/scripts)/.+)?[^/]+\.py$ + files: ^((.github/scripts|scripts)/.+)?[^/]+\.py$ + exclude: (split_photos.py) - id: ruff-format - files: ^((.github/scripts)/.+)?[^/]+\.py$ + files: ^((.github/scripts|scripts)/.+)?[^/]+\.py$ + exclude: (split_photos.py) - repo: https://github.com/codespell-project/codespell rev: v2.2.6 hooks: @@ -33,5 +35,5 @@ repos: # args: ["--replace_with= "] entry: python .github/scripts/check_tabulator.py language: python - exclude: ^src/main/resources/static/pdfjs/ + exclude: ^(src/main/resources/static/pdfjs|src/main/resources/static/pdfjs-legacy) files: ^.*(\.html|\.css|\.js)$ diff --git a/README.md b/README.md index 480e3bdd..c231601e 100644 --- a/README.md +++ b/README.md @@ -187,7 +187,7 @@ Stirling PDF currently supports 32! | Russian (Русский) (ru_RU) | ![86%](https://geps.dev/progress/86) | | Basque (Euskara) (eu_ES) | ![63%](https://geps.dev/progress/63) | | Japanese (日本語) (ja_JP) | ![92%](https://geps.dev/progress/92) | -| Dutch (Nederlands) (nl_NL) | ![97%](https://geps.dev/progress/97) | +| Dutch (Nederlands) (nl_NL) | ![98%](https://geps.dev/progress/98) | | Greek (Ελληνικά) (el_GR) | ![84%](https://geps.dev/progress/84) | | Turkish (Türkçe) (tr_TR) | ![96%](https://geps.dev/progress/96) | | Indonesia (Bahasa Indonesia) (id_ID) | ![78%](https://geps.dev/progress/78) | diff --git a/Version-groups.md b/Version-groups.md index a9a9ac16..0e1bc092 100644 --- a/Version-groups.md +++ b/Version-groups.md @@ -1,4 +1,4 @@ -|All versions in a Docker envrionment can download Calibre as a optional extra at runtime to support `book-to-pdf` and `pdf-to-book` using parameter ``INSTALL_BOOK_AND_ADVANCED_HTML_OPS``. +|All versions in a Docker environment can download Calibre as a optional extra at runtime to support `book-to-pdf` and `pdf-to-book` using parameter ``INSTALL_BOOK_AND_ADVANCED_HTML_OPS``. The 'Fat' container contains all those found in 'Full' with security jar along with this Calibre install. Technology | Ultra-Lite | Full | diff --git a/scripts/counter_translation.py b/scripts/counter_translation.py index a4b6255b..7f17d377 100644 --- a/scripts/counter_translation.py +++ b/scripts/counter_translation.py @@ -79,7 +79,9 @@ def write_readme(progress_list: list[tuple[str, int]]) -> None: file.writelines(content) -def compare_files(default_file_path, file_paths, translation_status_file) -> list[tuple[str, int]]: +def compare_files( + default_file_path, file_paths, ignore_translation_file +) -> list[tuple[str, int]]: """Compares the default properties file with other properties files in the directory. @@ -92,18 +94,24 @@ def compare_files(default_file_path, file_paths, translation_status_file) -> lis language and progress percentage. """ # noqa: D205 num_lines = sum( - 1 for line in open(default_file_path, encoding="utf-8") if line.strip() and not line.strip().startswith("#") + 1 + for line in open(default_file_path, encoding="utf-8") + if line.strip() and not line.strip().startswith("#") ) result_list = [] - sort_translation_status: tomlkit.TOMLDocument + sort_ignore_translation: tomlkit.TOMLDocument # read toml - with open(translation_status_file, encoding="utf-8") as f: - sort_translation_status = tomlkit.parse(f.read()) + with open(ignore_translation_file, encoding="utf-8") as f: + sort_ignore_translation = tomlkit.parse(f.read()) for file_path in file_paths: - language = os.path.basename(file_path).split("messages_", 1)[1].split(".properties", 1)[0] + language = ( + os.path.basename(file_path) + .split("messages_", 1)[1] + .split(".properties", 1)[0] + ) fails = 0 if "en_GB" in language or "en_US" in language: @@ -111,21 +119,25 @@ def compare_files(default_file_path, file_paths, translation_status_file) -> lis result_list.append(("en_US", 100)) continue - if language not in sort_translation_status: - sort_translation_status[language] = tomlkit.table() + if language not in sort_ignore_translation: + sort_ignore_translation[language] = tomlkit.table() if ( - "ignore" not in sort_translation_status[language] - or len(sort_translation_status[language].get("ignore", [])) < 1 + "ignore" not in sort_ignore_translation[language] + or len(sort_ignore_translation[language].get("ignore", [])) < 1 ): - sort_translation_status[language]["ignore"] = tomlkit.array(["language.direction"]) + sort_ignore_translation[language]["ignore"] = tomlkit.array( + ["language.direction"] + ) - # if "missing" not in sort_translation_status[language]: - # sort_translation_status[language]["missing"] = tomlkit.array() - # elif "language.direction" in sort_translation_status[language]["missing"]: - # sort_translation_status[language]["missing"].remove("language.direction") + # if "missing" not in sort_ignore_translation[language]: + # sort_ignore_translation[language]["missing"] = tomlkit.array() + # elif "language.direction" in sort_ignore_translation[language]["missing"]: + # sort_ignore_translation[language]["missing"].remove("language.direction") - with open(default_file_path, encoding="utf-8") as default_file, open(file_path, encoding="utf-8") as file: + with open(default_file_path, encoding="utf-8") as default_file, open( + file_path, encoding="utf-8" + ) as file: for _ in range(5): next(default_file) try: @@ -133,34 +145,45 @@ def compare_files(default_file_path, file_paths, translation_status_file) -> lis except StopIteration: fails = num_lines - for line_num, (line_default, line_file) in enumerate(zip(default_file, file), start=6): + for line_num, (line_default, line_file) in enumerate( + zip(default_file, file), start=6 + ): try: # Ignoring empty lines and lines start with # if line_default.strip() == "" or line_default.startswith("#"): continue - default_key, default_value = line_default.split("=", 1) file_key, file_value = line_file.split("=", 1) if ( default_value.strip() == file_value.strip() - and default_key.strip() not in sort_translation_status[language]["ignore"] + and default_key.strip() + not in sort_ignore_translation[language]["ignore"] ): - print(f"{language}: Line {line_num} is missing the translation.") - # if default_key.strip() not in sort_translation_status[language]["missing"]: + print( + f"{language}: Line {line_num} is missing the translation." + ) + # if default_key.strip() not in sort_ignore_translation[language]["missing"]: # missing_array = tomlkit.array() # missing_array.append(default_key.strip()) # missing_array.multiline(True) - # sort_translation_status[language]["missing"].extend(missing_array) + # sort_ignore_translation[language]["missing"].extend(missing_array) fails += 1 - # elif default_key.strip() in sort_translation_status[language]["ignore"]: - # if default_key.strip() in sort_translation_status[language]["missing"]: - # sort_translation_status[language]["missing"].remove(default_key.strip()) + # elif default_key.strip() in sort_ignore_translation[language]["ignore"]: + # if default_key.strip() in sort_ignore_translation[language]["missing"]: + # sort_ignore_translation[language]["missing"].remove(default_key.strip()) if default_value.strip() != file_value.strip(): - # if default_key.strip() in sort_translation_status[language]["missing"]: - # sort_translation_status[language]["missing"].remove(default_key.strip()) - if default_key.strip() in sort_translation_status[language]["ignore"]: - sort_translation_status[language]["ignore"].remove(default_key.strip()) - + # if default_key.strip() in sort_ignore_translation[language]["missing"]: + # sort_ignore_translation[language]["missing"].remove(default_key.strip()) + if ( + default_key.strip() + in sort_ignore_translation[language]["ignore"] + ): + sort_ignore_translation[language]["ignore"].remove( + default_key.strip() + ) + except ValueError: + print(f"{line_default}|{line_file}") + exit(1) except IndexError: pass @@ -171,9 +194,9 @@ def compare_files(default_file_path, file_paths, translation_status_file) -> lis int((num_lines - fails) * 100 / num_lines), ) ) - translation_status = convert_to_multiline(sort_translation_status) - with open(translation_status_file, "w", encoding="utf-8") as file: - file.write(tomlkit.dumps(translation_status)) + ignore_translation = convert_to_multiline(sort_ignore_translation) + with open(ignore_translation_file, "w", encoding="utf-8") as file: + file.write(tomlkit.dumps(ignore_translation)) unique_data = list(set(result_list)) unique_data.sort(key=lambda x: x[1], reverse=True) @@ -187,6 +210,8 @@ if __name__ == "__main__": reference_file = os.path.join(directory, "messages_en_GB.properties") scripts_directory = os.path.join(os.getcwd(), "scripts") - translation_state_file = os.path.join(scripts_directory, "translation_status.toml") + translation_state_file = os.path.join(scripts_directory, "ignore_translation.toml") - write_readme(compare_files(reference_file, messages_file_paths, translation_state_file)) + write_readme( + compare_files(reference_file, messages_file_paths, translation_state_file) + ) diff --git a/scripts/ignore_translation.toml b/scripts/ignore_translation.toml index b4990ff6..682b4b4c 100644 --- a/scripts/ignore_translation.toml +++ b/scripts/ignore_translation.toml @@ -1,15 +1,194 @@ +[ar_AR] +ignore = [ + 'language.direction', +] + +[bg_BG] +ignore = [ + 'language.direction', +] + +[ca_CA] +ignore = [ + 'language.direction', +] + +[cs_CZ] +ignore = [ + 'info', + 'language.direction', + 'pipeline.header', + 'text', +] + +[de_DE] +ignore = [ + 'AddStampRequest.alphabet', + 'AddStampRequest.position', + 'PDFToBook.selectText.1', + 'PDFToText.tags', + 'addPageNumbers.selectText.3', + 'alphabet', + 'certSign.name', + 'language.direction', + 'licenses.version', + 'pipeline.title', + 'pipelineOptions.pipelineHeader', + 'sponsor', + 'text', + 'watermark.type.1', +] + +[el_GR] +ignore = [ + 'language.direction', +] + +[es_ES] +ignore = [ + 'adminUserSettings.roles', + 'color', + 'language.direction', + 'no', + 'showJS.tags', +] + +[eu_ES] +ignore = [ + 'language.direction', +] + +[fr_FR] +ignore = [ + 'language.direction', + 'sponsor', +] + +[hi_IN] +ignore = [ + 'language.direction', +] + +[hr_HR] +ignore = [ + 'font', + 'home.pipeline.title', + 'info', + 'language.direction', + 'pdfOrganiser.tags', + 'showJS.tags', +] + +[hu_HU] +ignore = [ + 'language.direction', +] + +[id_ID] +ignore = [ + 'language.direction', +] + +[it_IT] +ignore = [ + 'font', + 'language.direction', + 'no', + 'password', + 'pipeline.title', + 'pipelineOptions.pipelineHeader', + 'removePassword.selectText.2', + 'showJS.tags', + 'sponsor', +] + +[ja_JP] +ignore = [ + 'language.direction', +] + +[ko_KR] +ignore = [ + 'language.direction', +] + [nl_NL] ignore = [ - "language.direction", - "error", - "help", - "sponsor", - "info", - "navbar.allTools", - "showJS.downloadJS", - "getPdfInfo.downloadJson", - "HTMLToPDF.print", - "compare.document.1", - "compare.document.2", - "printFile.submit" + 'HTMLToPDF.print', + 'compare.document.1', + 'compare.document.2', + 'error', + 'getPdfInfo.downloadJson', + 'help', + 'info', + 'language.direction', + 'navbar.allTools', + 'printFile.submit', + 'showJS.downloadJS', + 'sponsor', +] + +[no_NB] +ignore = [ + 'language.direction', +] + +[pl_PL] +ignore = [ + 'language.direction', +] + +[pt_BR] +ignore = [ + 'language.direction', +] + +[pt_PT] +ignore = [ + 'language.direction', +] + +[ro_RO] +ignore = [ + 'language.direction', +] + +[ru_RU] +ignore = [ + 'language.direction', +] + +[sk_SK] +ignore = [ + 'language.direction', +] + +[sr_LATN_RS] +ignore = [ + 'language.direction', +] + +[sv_SE] +ignore = [ + 'language.direction', +] + +[tr_TR] +ignore = [ + 'language.direction', +] + +[uk_UA] +ignore = [ + 'language.direction', +] + +[zh_CN] +ignore = [ + 'language.direction', +] + +[zh_TW] +ignore = [ + 'language.direction', ] diff --git a/scripts/translation_status.toml b/scripts/translation_status.toml deleted file mode 100644 index 0a8afe75..00000000 --- a/scripts/translation_status.toml +++ /dev/null @@ -1,183 +0,0 @@ -[ar_AR] -ignore = [ - 'language.direction', -] - -[bg_BG] -ignore = [ - 'language.direction', -] - -[ca_CA] -ignore = [ - 'language.direction', -] - -[cs_CZ] -ignore = [ - 'info', - 'language.direction', - 'pipeline.header', - 'text', -] - -[de_DE] -ignore = [ - 'AddStampRequest.alphabet', - 'AddStampRequest.position', - 'PDFToBook.selectText.1', - 'PDFToText.tags', - 'addPageNumbers.selectText.3', - 'alphabet', - 'certSign.name', - 'language.direction', - 'licenses.version', - 'pipeline.title', - 'pipelineOptions.pipelineHeader', - 'sponsor', - 'text', - 'watermark.type.1', -] - -[el_GR] -ignore = [ - 'language.direction', -] - -[es_ES] -ignore = [ - 'adminUserSettings.roles', - 'color', - 'language.direction', - 'no', - 'showJS.tags', -] - -[eu_ES] -ignore = [ - 'language.direction', -] - -[fr_FR] -ignore = [ - 'language.direction', - 'sponsor', -] - -[hi_IN] -ignore = [ - 'language.direction', -] - -[hr_HR] -ignore = [ - 'font', - 'home.pipeline.title', - 'info', - 'language.direction', - 'pdfOrganiser.tags', - 'showJS.tags', -] - -[hu_HU] -ignore = [ - 'language.direction', -] - -[id_ID] -ignore = [ - 'language.direction', -] - -[it_IT] -ignore = [ - 'font', - 'language.direction', - 'no', - 'password', - 'pipeline.title', - 'pipelineOptions.pipelineHeader', - 'removePassword.selectText.2', - 'showJS.tags', - 'sponsor', -] - -[ja_JP] -ignore = [ - 'language.direction', -] - -[ko_KR] -ignore = [ - 'language.direction', -] - -[nl_NL] -ignore = [ - 'language.direction', -] - -[no_NB] -ignore = [ - 'language.direction', -] - -[pl_PL] -ignore = [ - 'language.direction', -] - -[pt_BR] -ignore = [ - 'language.direction', -] - -[pt_PT] -ignore = [ - 'language.direction', -] - -[ro_RO] -ignore = [ - 'language.direction', -] - -[ru_RU] -ignore = [ - 'language.direction', -] - -[sk_SK] -ignore = [ - 'language.direction', -] - -[sr_LATN_RS] -ignore = [ - 'language.direction', -] - -[sv_SE] -ignore = [ - 'language.direction', -] - -[tr_TR] -ignore = [ - 'language.direction', -] - -[uk_UA] -ignore = [ - 'language.direction', -] - -[zh_CN] -ignore = [ - 'language.direction', -] - -[zh_TW] -ignore = [ - 'language.direction', -]