@@ -88,7 +88,12 @@ def convert_xliff_to_string_catalog(input_dir, output_dir, source_language, targ
88
88
"version" : "1.0"
89
89
}
90
90
91
- for language in [source_language ] + target_languages :
91
+ # We need to sort the full language list (if the source language comes first rather than in alphabetical order
92
+ # then the output will differ from what Xcode generates)
93
+ all_languages = [source_language ] + target_languages
94
+ sorted_languages = sorted (all_languages , key = lambda x : x ['id' ])
95
+
96
+ for language in sorted_languages :
92
97
lang_locale = language ['locale' ]
93
98
input_file = os .path .join (input_dir , f"{ lang_locale } .xliff" )
94
99
@@ -165,7 +170,9 @@ def convert_xliff_to_string_catalog(input_dir, output_dir, source_language, targ
165
170
os .makedirs (output_dir , exist_ok = True )
166
171
167
172
with open (output_file , 'w' , encoding = 'utf-8' ) as f :
168
- json .dump (string_catalog , f , ensure_ascii = False , indent = 2 )
173
+ # We need to add spaces around the `:` in the output beacuse Xcode inserts one when opening
174
+ # the `xcstrings` so if we don't then there is an absurd number of diffs...
175
+ json .dump (string_catalog , f , ensure_ascii = False , indent = 2 , separators = (',' , ' : ' ))
169
176
170
177
def convert_non_translatable_strings_to_swift (input_file , output_path ):
171
178
if not os .path .exists (input_file ):
0 commit comments