diff --git a/devkit/i18n-lint.py b/devkit/i18n-lint.py new file mode 100644 index 0000000..03d64ed --- /dev/null +++ b/devkit/i18n-lint.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +import os +import subprocess + +def lint_strings_files(directory): + for root, _, files in os.walk(directory): + for file in files: + if file.endswith('.strings') or file.endswith('.stringsdict'): + file_path = os.path.join(root, file) + try: + subprocess.run(['plutil', '-lint', file_path], check=True) + print(f"Linting passed for {file_path}") + except subprocess.CalledProcessError: + print(f"Linting failed for {file_path}") + +if __name__ == "__main__": + lint_strings_files('res') diff --git a/devkit/i18n-statistics.py b/devkit/i18n-statistics.py index 18ab380..f23bfda 100755 --- a/devkit/i18n-statistics.py +++ b/devkit/i18n-statistics.py @@ -2,6 +2,7 @@ import matplotlib.pyplot as plt import pathlib +import plistlib lproj_base = pathlib.Path('res') @@ -20,7 +21,7 @@ def get_lproj_path(lang) -> pathlib.Path: return lproj_base / f'{lang}.lproj' -def get_lproj_strings_paths(lang) -> [pathlib.Path]: +def get_lproj_strings_paths(lang) -> list[pathlib.Path]: return [ get_lproj_path(lang) / 'Localizable.strings', get_lproj_path(lang) / 'InfoPlist.strings', @@ -29,20 +30,36 @@ def get_lproj_strings_paths(lang) -> [pathlib.Path]: def get_lproj_strings_count(lang) -> tuple[int, int]: all_lines = [] for strings_path in get_lproj_strings_paths(lang): - if strings_path.exists(): - with open(strings_path, 'r') as f: - all_lines.extend(f.readlines()) + if not strings_path.exists(): + continue + with open(strings_path, 'r') as f: + all_lines.extend(f.readlines()) todo_count = 0 for line in all_lines: if line.find('/* TODO */') != -1 or line.find('/* Translated with ') != -1: todo_count += 1 return int((len(all_lines) + 1) / 3), todo_count +def get_lproj_stringsdict_paths(lang) -> list[pathlib.Path]: + return [ + get_lproj_path(lang) / 'Localizable.stringsdict', + ] + +def get_lproj_stringsdict_count(lang) -> int: + all_count = 0 + for stringsdict_path in get_lproj_stringsdict_paths(lang): + if not stringsdict_path.exists(): + continue + stringsdict = plistlib.load(open(stringsdict_path, 'rb')) + all_count += len(stringsdict) + return all_count + if __name__ == '__main__': x_labels = available_languages y_values = [] for lang in available_languages: total, todo = get_lproj_strings_count(lang) + total += get_lproj_stringsdict_count(lang) percent = (total - todo) / total y_values.append((lang, percent, total - todo, total)) print(f'{lang}: {total - todo}/{total} translated, {percent * 100:.2f}%') diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e34a298 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,11 @@ +contourpy==1.3.1 +cycler==0.12.1 +fonttools==4.55.0 +kiwisolver==1.4.7 +matplotlib==3.9.2 +numpy==2.1.3 +packaging==24.2 +pillow==11.0.0 +pyparsing==3.2.0 +python-dateutil==2.9.0.post0 +six==1.16.0 diff --git a/res/stats.png b/res/stats.png index ac663a1..00632b4 100644 Binary files a/res/stats.png and b/res/stats.png differ