mirror of
https://github.com/google/blockly.git
synced 2026-01-05 08:00:09 +01:00
Merge branch 'develop' into merge-v11
This commit is contained in:
@@ -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}"];'
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user