diff --git a/lang/string_extractor/parse.py b/lang/string_extractor/parse.py index 3fd5f3658f8d3..c96f503a34384 100644 --- a/lang/string_extractor/parse.py +++ b/lang/string_extractor/parse.py @@ -12,7 +12,12 @@ def parse_json_object(json, origin): if "type" in json and type(json["type"]) is str: json_type = json["type"].lower() if json_type in parsers: - parsers[json_type](json, origin) + try: + parsers[json_type](json, origin) + except Exception as E: + print("Exception when parsing JSON data type \"{}\"" + .format(json_type)) + raise E else: raise Exception("Unrecognized JSON data type \"{}\"" .format(json_type)) diff --git a/lang/string_extractor/parsers/npc_class.py b/lang/string_extractor/parsers/npc_class.py index 1db3dac9b5faa..1fa94193d6051 100644 --- a/lang/string_extractor/parsers/npc_class.py +++ b/lang/string_extractor/parsers/npc_class.py @@ -4,8 +4,14 @@ def parse_npc_class(json, origin): comment = json.get("//", None) - name = get_singular_name(json["name"]) - write_text(json["name"], origin, comment=["Name of an NPC class", comment]) - write_text(json["job_description"], origin, - comment=["Job description of \"{}\" NPC class".format(name), - comment]) + name = "" + if "name" in json: + name = get_singular_name(json["name"]) + write_text(json["name"], origin, + comment=["Name of an NPC class", comment]) + elif "id" in json: + name = json["id"] + if "job_description" in json: + write_text(json["job_description"], origin, + comment=["Job description of \"{}\" NPC class".format(name), + comment]) diff --git a/lang/string_extractor/parsers/profession.py b/lang/string_extractor/parsers/profession.py index 5920223c30ea8..82c0a35398181 100644 --- a/lang/string_extractor/parsers/profession.py +++ b/lang/string_extractor/parsers/profession.py @@ -4,7 +4,9 @@ def parse_profession(json, origin): name_male = "" name_female = "" - if type(json["name"]) is dict: + if "name" not in json: + name_male = name_female = json["id"] + elif type(json["name"]) is dict: name_male = json["name"]["male"] name_female = json["name"]["female"] elif type(json["name"]) is str: diff --git a/lang/string_extractor/parsers/speech.py b/lang/string_extractor/parsers/speech.py index a914de3511e83..7b61ba1244d10 100644 --- a/lang/string_extractor/parsers/speech.py +++ b/lang/string_extractor/parsers/speech.py @@ -2,7 +2,12 @@ def parse_speech(json, origin): - speaker = ", ".join(json.get("speaker", [])) + speaker = "" + if "speaker" in json: + if type(json["speaker"]) is list: + speaker = ", ".join(json.get("speaker", [])) + elif type(json["speaker"]) is str: + speaker = json["speaker"] if "sound" in json: write_text(json["sound"], origin, c_format=False, comment="Speech from speaker {}".format(speaker))