Rename from translation_status.toml to ignore_translation.toml and more (#1511)

This commit is contained in:
Ludy 2024-06-26 22:47:20 +02:00 committed by GitHub
parent a2d7490d45
commit 88e8663d44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 265 additions and 242 deletions

View File

@ -7,7 +7,7 @@ on:
paths: paths:
- "build.gradle" - "build.gradle"
- "src/main/resources/messages_*.properties" - "src/main/resources/messages_*.properties"
- "scripts/translation_status.toml" - "scripts/ignore_translation.toml"
permissions: permissions:
contents: write contents: write
@ -17,9 +17,9 @@ jobs:
sync-versions: sync-versions:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4.1.1 - uses: actions/checkout@v4
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5.1.0 uses: actions/setup-python@v5
with: with:
python-version: "3.x" python-version: "3.x"
- name: Install dependencies - name: Install dependencies
@ -36,7 +36,7 @@ jobs:
git diff --staged --quiet || git commit -m ":floppy_disk: Sync Versions git diff --staged --quiet || git commit -m ":floppy_disk: Sync Versions
> Made via sync_files.yml" || echo "no changes" > Made via sync_files.yml" || echo "no changes"
- name: Create Pull Request - name: Create Pull Request
uses: peter-evans/create-pull-request@v6.0.1 uses: peter-evans/create-pull-request@v6
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update files commit-message: Update files
@ -54,9 +54,9 @@ jobs:
sync-readme: sync-readme:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4.1.1 - uses: actions/checkout@v4
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5.1.0 uses: actions/setup-python@v5
with: with:
python-version: "3.x" python-version: "3.x"
- name: Install dependencies - name: Install dependencies
@ -73,7 +73,7 @@ jobs:
git diff --staged --quiet || git commit -m ":memo: Sync README git diff --staged --quiet || git commit -m ":memo: Sync README
> Made via sync_files.yml" || echo "no changes" > Made via sync_files.yml" || echo "no changes"
- name: Create Pull Request - name: Create Pull Request
uses: peter-evans/create-pull-request@v6.0.1 uses: peter-evans/create-pull-request@v6
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update files commit-message: Update files

View File

@ -6,9 +6,11 @@ repos:
args: args:
- --fix - --fix
- --line-length=127 - --line-length=127
files: ^((.github/scripts)/.+)?[^/]+\.py$ files: ^((.github/scripts|scripts)/.+)?[^/]+\.py$
exclude: (split_photos.py)
- id: ruff-format - id: ruff-format
files: ^((.github/scripts)/.+)?[^/]+\.py$ files: ^((.github/scripts|scripts)/.+)?[^/]+\.py$
exclude: (split_photos.py)
- repo: https://github.com/codespell-project/codespell - repo: https://github.com/codespell-project/codespell
rev: v2.2.6 rev: v2.2.6
hooks: hooks:
@ -33,5 +35,5 @@ repos:
# args: ["--replace_with= "] # args: ["--replace_with= "]
entry: python .github/scripts/check_tabulator.py entry: python .github/scripts/check_tabulator.py
language: python language: python
exclude: ^src/main/resources/static/pdfjs/ exclude: ^(src/main/resources/static/pdfjs|src/main/resources/static/pdfjs-legacy)
files: ^.*(\.html|\.css|\.js)$ files: ^.*(\.html|\.css|\.js)$

View File

@ -187,7 +187,7 @@ Stirling PDF currently supports 32!
| Russian (Русский) (ru_RU) | ![86%](https://geps.dev/progress/86) | | Russian (Русский) (ru_RU) | ![86%](https://geps.dev/progress/86) |
| Basque (Euskara) (eu_ES) | ![63%](https://geps.dev/progress/63) | | Basque (Euskara) (eu_ES) | ![63%](https://geps.dev/progress/63) |
| Japanese (日本語) (ja_JP) | ![92%](https://geps.dev/progress/92) | | 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) | | Greek (Ελληνικά) (el_GR) | ![84%](https://geps.dev/progress/84) |
| Turkish (Türkçe) (tr_TR) | ![96%](https://geps.dev/progress/96) | | Turkish (Türkçe) (tr_TR) | ![96%](https://geps.dev/progress/96) |
| Indonesia (Bahasa Indonesia) (id_ID) | ![78%](https://geps.dev/progress/78) | | Indonesia (Bahasa Indonesia) (id_ID) | ![78%](https://geps.dev/progress/78) |

View File

@ -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. The 'Fat' container contains all those found in 'Full' with security jar along with this Calibre install.
Technology | Ultra-Lite | Full | Technology | Ultra-Lite | Full |

View File

@ -79,7 +79,9 @@ def write_readme(progress_list: list[tuple[str, int]]) -> None:
file.writelines(content) 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 """Compares the default properties file with other
properties files in the directory. 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. language and progress percentage.
""" # noqa: D205 """ # noqa: D205
num_lines = sum( 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 = [] result_list = []
sort_translation_status: tomlkit.TOMLDocument sort_ignore_translation: tomlkit.TOMLDocument
# read toml # read toml
with open(translation_status_file, encoding="utf-8") as f: with open(ignore_translation_file, encoding="utf-8") as f:
sort_translation_status = tomlkit.parse(f.read()) sort_ignore_translation = tomlkit.parse(f.read())
for file_path in file_paths: 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 fails = 0
if "en_GB" in language or "en_US" in language: 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)) result_list.append(("en_US", 100))
continue continue
if language not in sort_translation_status: if language not in sort_ignore_translation:
sort_translation_status[language] = tomlkit.table() sort_ignore_translation[language] = tomlkit.table()
if ( if (
"ignore" not in sort_translation_status[language] "ignore" not in sort_ignore_translation[language]
or len(sort_translation_status[language].get("ignore", [])) < 1 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]: # if "missing" not in sort_ignore_translation[language]:
# sort_translation_status[language]["missing"] = tomlkit.array() # sort_ignore_translation[language]["missing"] = tomlkit.array()
# elif "language.direction" in sort_translation_status[language]["missing"]: # elif "language.direction" in sort_ignore_translation[language]["missing"]:
# sort_translation_status[language]["missing"].remove("language.direction") # 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): for _ in range(5):
next(default_file) next(default_file)
try: try:
@ -133,34 +145,45 @@ def compare_files(default_file_path, file_paths, translation_status_file) -> lis
except StopIteration: except StopIteration:
fails = num_lines 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: try:
# Ignoring empty lines and lines start with # # Ignoring empty lines and lines start with #
if line_default.strip() == "" or line_default.startswith("#"): if line_default.strip() == "" or line_default.startswith("#"):
continue continue
default_key, default_value = line_default.split("=", 1) default_key, default_value = line_default.split("=", 1)
file_key, file_value = line_file.split("=", 1) file_key, file_value = line_file.split("=", 1)
if ( if (
default_value.strip() == file_value.strip() 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.") print(
# if default_key.strip() not in sort_translation_status[language]["missing"]: 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 = tomlkit.array()
# missing_array.append(default_key.strip()) # missing_array.append(default_key.strip())
# missing_array.multiline(True) # missing_array.multiline(True)
# sort_translation_status[language]["missing"].extend(missing_array) # sort_ignore_translation[language]["missing"].extend(missing_array)
fails += 1 fails += 1
# elif default_key.strip() in sort_translation_status[language]["ignore"]: # elif default_key.strip() in sort_ignore_translation[language]["ignore"]:
# if default_key.strip() in sort_translation_status[language]["missing"]: # if default_key.strip() in sort_ignore_translation[language]["missing"]:
# sort_translation_status[language]["missing"].remove(default_key.strip()) # sort_ignore_translation[language]["missing"].remove(default_key.strip())
if default_value.strip() != file_value.strip(): if default_value.strip() != file_value.strip():
# if default_key.strip() in sort_translation_status[language]["missing"]: # if default_key.strip() in sort_ignore_translation[language]["missing"]:
# sort_translation_status[language]["missing"].remove(default_key.strip()) # sort_ignore_translation[language]["missing"].remove(default_key.strip())
if default_key.strip() in sort_translation_status[language]["ignore"]: if (
sort_translation_status[language]["ignore"].remove(default_key.strip()) 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: except IndexError:
pass pass
@ -171,9 +194,9 @@ def compare_files(default_file_path, file_paths, translation_status_file) -> lis
int((num_lines - fails) * 100 / num_lines), int((num_lines - fails) * 100 / num_lines),
) )
) )
translation_status = convert_to_multiline(sort_translation_status) ignore_translation = convert_to_multiline(sort_ignore_translation)
with open(translation_status_file, "w", encoding="utf-8") as file: with open(ignore_translation_file, "w", encoding="utf-8") as file:
file.write(tomlkit.dumps(translation_status)) file.write(tomlkit.dumps(ignore_translation))
unique_data = list(set(result_list)) unique_data = list(set(result_list))
unique_data.sort(key=lambda x: x[1], reverse=True) 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") reference_file = os.path.join(directory, "messages_en_GB.properties")
scripts_directory = os.path.join(os.getcwd(), "scripts") 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)
)

View File

@ -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] [nl_NL]
ignore = [ ignore = [
"language.direction", 'HTMLToPDF.print',
"error", 'compare.document.1',
"help", 'compare.document.2',
"sponsor", 'error',
"info", 'getPdfInfo.downloadJson',
"navbar.allTools", 'help',
"showJS.downloadJS", 'info',
"getPdfInfo.downloadJson", 'language.direction',
"HTMLToPDF.print", 'navbar.allTools',
"compare.document.1", 'printFile.submit',
"compare.document.2", 'showJS.downloadJS',
"printFile.submit" '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',
] ]

View File

@ -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',
]