|
1 | 1 | import os |
2 | 2 | import json |
| 3 | +from typing import Dict, List |
3 | 4 | import xml.etree.ElementTree as ET |
4 | 5 | import sys |
5 | 6 | import argparse |
|
37 | 38 | TRANSLATIONS_OUTPUT_DIRECTORY = args.translations_output_directory |
38 | 39 | NON_TRANSLATABLE_STRINGS_OUTPUT_PATH = args.non_translatable_strings_output_path |
39 | 40 |
|
40 | | -clean_string_extra_dict = {'{count}': '#'} |
41 | 41 |
|
42 | 42 | def parse_xliff(file_path): |
43 | 43 | tree = ET.parse(file_path) |
@@ -72,17 +72,17 @@ def parse_xliff(file_path): |
72 | 72 | return translations |
73 | 73 |
|
74 | 74 |
|
75 | | -def generate_icu_pattern(target, glossary_dict): |
| 75 | +def generate_icu_pattern(target, glossary_dict : Dict[str,str]): |
76 | 76 | if isinstance(target, dict): # It's a plural group |
77 | 77 | pattern_parts = [] |
78 | 78 | for form, value in target.items(): |
79 | 79 | if form in ['zero', 'one', 'two', 'few', 'many', 'other', 'exact', 'fractional']: |
80 | | - value = clean_string(value, False, glossary_dict, clean_string_extra_dict) |
| 80 | + value = clean_string(value, False, glossary_dict, {}) |
81 | 81 | pattern_parts.append(f"{form} [{value}]") |
82 | 82 |
|
83 | 83 | return "{{count, plural, {0}}}".format(" ".join(pattern_parts)) |
84 | 84 | else: # It's a regular string |
85 | | - return clean_string(target, False, glossary_dict, clean_string_extra_dict) |
| 85 | + return clean_string(target, False, glossary_dict, {}) |
86 | 86 |
|
87 | 87 | def convert_xliff_to_json(input_file, output_dir, locale, locale_two_letter_code, glossary_dict): |
88 | 88 | if not os.path.exists(input_file): |
@@ -110,7 +110,7 @@ def convert_xliff_to_json(input_file, output_dir, locale, locale_two_letter_code |
110 | 110 |
|
111 | 111 |
|
112 | 112 |
|
113 | | -def convert_non_translatable_strings_to_type_script(input_file, output_path, exported_locales, rtl_languages): |
| 113 | +def convert_non_translatable_strings_to_type_script(input_file: str, output_path: str, exported_locales: List[str], rtl_languages: List[str]): |
114 | 114 | glossary_dict = load_glossary_dict(input_file) |
115 | 115 | rtl_locales = sorted([lang["twoLettersCode"] for lang in rtl_languages]) |
116 | 116 |
|
@@ -140,7 +140,7 @@ def convert_non_translatable_strings_to_type_script(input_file, output_path, exp |
140 | 140 | file.write('\n') |
141 | 141 |
|
142 | 142 |
|
143 | | -def convert_all_files(input_directory): |
| 143 | +def convert_all_files(input_directory: str): |
144 | 144 | setup_values = setup_generation(input_directory) |
145 | 145 | source_language, rtl_languages, non_translatable_strings_file, target_languages = setup_values.values() |
146 | 146 |
|
|
0 commit comments