Merge branch 'develop' into merge-v11

This commit is contained in:
Maribeth Moffatt
2024-05-13 11:20:39 -07:00
25 changed files with 298 additions and 84 deletions

View File

@@ -37,12 +37,13 @@ def string_is_ascii(s):
def load_constants(filename):
"""Read in constants file, which must be output in every language."""
constant_defs = read_json_file(filename)
if '#' in constant_defs: # Delete any comment.
del constant_defs['#']
constants_text = '\n'
for key in constant_defs:
value = constant_defs[key]
value = value.replace('"', '\\"')
constants_text += u'\nBlockly.Msg["{0}"] = \"{1}\";'.format(
key, value)
constants_text += u'\nBlockly.Msg["{0}"] = \"{1}\";'.format(key, value)
return constants_text
def main():
@@ -86,6 +87,8 @@ def main():
# Read in synonyms file, which must be output in every language.
synonym_defs = read_json_file(os.path.join(
os.curdir, args.source_synonym_file))
if '#' in synonym_defs: # Delete any comment.
del synonym_defs['#']
# synonym_defs is also being sorted to ensure the same order is kept
synonym_text = '\n'.join([u'Blockly.Msg["{0}"] = Blockly.Msg["{1}"];'

View File

@@ -114,29 +114,22 @@ def main():
write_files(args.author, args.lang, args.output_dir, results, False)
# Create synonyms.json.
synonyms_sorted = sort_dict(synonyms)
synonym_file_name = os.path.join(os.curdir, args.output_dir, 'synonyms.json')
synonyms['#'] = 'Automatically generated, do not edit this file!'
with open(synonym_file_name, 'w') as outfile:
json.dump(synonyms_sorted, outfile)
json.dump(synonyms, outfile, indent=2, sort_keys=True)
if not args.quiet:
print("Wrote {0} synonym pairs to {1}.".format(
len(synonyms_sorted), synonym_file_name))
len(synonyms) - 1, synonym_file_name))
# Create constants.json
constants_sorted = sort_dict(constants)
constants_file_name = os.path.join(os.curdir, args.output_dir, 'constants.json')
constants['#'] = 'Automatically generated, do not edit this file!'
with open(constants_file_name, 'w') as outfile:
json.dump(constants_sorted, outfile)
json.dump(constants, outfile, indent=2, sort_keys=True)
if not args.quiet:
print("Wrote {0} constant pairs to {1}.".format(
len(constants_sorted), synonym_file_name))
def sort_dict(unsorted_dict):
# Sort the dictionary (thereby enabling better diffing of changes).
myKeys = list(unsorted_dict.keys())
myKeys.sort()
sorted_dict = {i: unsorted_dict[i] for i in myKeys}
return sorted_dict
len(constants) - 1, synonym_file_name))
if __name__ == '__main__':
main()