always remove  key from translation_dict
@@ -157,10 +157,6 @@ def get_tag_names(language_code: str, tag_field: dict):
tag_names_default = _read_translation_file("en", "tag_names")
tag_names_lang = _read_translation_file(language_code, "tag_names")
- # Remove the "@metadata" key from both dictionaries
- tag_names_default.pop("@metadata")
- tag_names_lang.pop("@metadata")
-
if tag_field:
for tag in tag_field["tags"]:
if tag in tag_names_lang:
@@ -188,10 +184,6 @@ def get_tag_choices():
tag_names_default = _read_translation_file("en", "tag_names")
tag_names_lang = _read_translation_file(language_code, "tag_names")
- # Remove the "@metadata" key from both dictionaries
- tag_names_default.pop("@metadata")
- tag_names_lang.pop("@metadata")
-
for tag_key, tag_value in tag_names_default.items():
lang_keys = tag_names_lang.keys()
if tag_key in lang_keys:
@@ -226,7 +218,12 @@ def _read_translation_file(language_code: str, filename: str):
)
if os.path.isfile(filepath):
with open(filepath, "r") as translation_file:
- return json.load(translation_file)
+ translation_dict = json.load(translation_file)
+
+ # Remove the "@metadata" key from the dictionary
+ if "@metadata" in translation_dict:
+ translation_dict.pop("@metadata")
+ return translation_dict
else:
return {}
@@ -266,8 +263,6 @@ def get_tags_json_schema():
JSON Schema for tag names
"""
tags_json = _read_translation_file("en", "tag_names")
- # We don't need the metadata key, removing it
- tags_json.pop("@metadata")
tag_keys = list(tags_json.keys())
number_of_tags = len(tag_keys)
JSON_SCHEMA_TAGS = {
