Skip to content

Commit ac4e85a

Browse files
authored
Merge pull request #14 from session-foundation/feature/android-span-to-font
Clean non translatable strings
2 parents 8f27ff3 + 8bb96b3 commit ac4e85a

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

crowdin/generate_android_strings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ def convert_non_translatable_strings_to_kotlin(input_file, output_path):
136136
for key_lowercase in glossary_dict:
137137
key = key_lowercase.upper()
138138
text = glossary_dict[key_lowercase]
139-
file.write(f' const val {key:<{max_key_length}} = "{text}"\n')
139+
cleaned_text = clean_string(text, True, glossary_dict, {})
140+
file.write(f' const val {key:<{max_key_length}} = "{cleaned_text}"\n')
140141

141142
file.write('}\n')
142143
file.write('\n')

crowdin/generate_desktop_strings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ def convert_non_translatable_strings_to_type_script(input_file: str, output_path
126126
file.write('export enum LOCALE_DEFAULTS {\n')
127127
for key in glossary_dict:
128128
text = glossary_dict[key]
129-
file.write(f" {key} = '{text}',\n")
129+
cleaned_text = clean_string(text, False, glossary_dict, {})
130+
file.write(f" {key} = '{cleaned_text}',\n")
130131

131132
file.write('}\n')
132133
file.write('\n')

crowdin/generate_ios_strings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ def convert_non_translatable_strings_to_swift(input_file, output_paths):
244244
file.write(f'public enum {enum_name} {{\n')
245245
for key in glossary_dict:
246246
text = glossary_dict[key]
247-
file.write(f' public static let {key}: String = "{text}"\n')
247+
cleaned_text = clean_string(text, False, glossary_dict, {})
248+
file.write(f' public static let {key}: String = "{cleaned_text}"\n')
248249

249250
file.write('}\n')
250251

crowdin/generate_shared.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ def clean_string(text: str, is_android: bool, glossary_dict: Dict[str, str], ext
1717
text = text.replace("&lt;/b&gt;", "</b>")
1818
text = text.replace("&lt;/br&gt;", "\\n")
1919
text = text.replace("<br/>", "\\n")
20+
text = text.replace("&lt;span&gt;", '<font color="0">')
21+
text = text.replace("&lt;/span&gt;", '</font>')
22+
text = text.replace("<span>", '<font color="0">')
23+
text = text.replace("</span>", '</font>')
2024
text = text.replace("&", "&amp;") # Assume any remaining ampersands are desired
2125
else:
2226
text = html.unescape(text) # Unescape any HTML escaping

0 commit comments

Comments
 (0)