-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lessica <82flex@gmail.com>
- Loading branch information
Showing
4 changed files
with
233 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import matplotlib.pyplot as plt | ||
import pathlib | ||
|
||
|
||
lproj_base = pathlib.Path('res') | ||
|
||
available_languages = [ | ||
'en', | ||
'es', | ||
'fr', | ||
'ko', | ||
'vi', | ||
'zh-Hans', | ||
'zh-Hant-HK', | ||
'zh-Hant-TW', | ||
] | ||
|
||
def get_lproj_path(lang) -> pathlib.Path: | ||
return lproj_base / f'{lang}.lproj' | ||
|
||
def get_lproj_strings_paths(lang) -> [pathlib.Path]: | ||
return [ | ||
get_lproj_path(lang) / 'Localizable.strings', | ||
get_lproj_path(lang) / 'InfoPlist.strings', | ||
] | ||
|
||
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()) | ||
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 | ||
|
||
if __name__ == '__main__': | ||
x_labels = available_languages | ||
y_values = [] | ||
for lang in available_languages: | ||
total, todo = get_lproj_strings_count(lang) | ||
percent = (total - todo) / total | ||
y_values.append((lang, percent, total - todo, total)) | ||
print(f'{lang}: {total - todo}/{total} translated, {percent * 100:.2f}%') | ||
y_values.sort(key=lambda x: 1.0 - x[1]) | ||
y_values.reverse() | ||
plt.figure().set_figwidth(15) | ||
plt.barh([x[0] for x in y_values], [x[2] for x in y_values]) | ||
plt.xlabel('Strings Translated') | ||
plt.ylabel('Language') | ||
plt.title('Translation Progress') | ||
plt.savefig(lproj_base / 'stats.png') |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.