我想把以下嵌套字典按语言分成不同的字典,并为每种语言创建一个新的JSON文件/字典。之后我想把它们合并在一起。感谢任何建议如何继续!
例如:
例如:
{
"All": {
"label_es_ES": "Todo",
"label_it_IT": "Tutto",
"label_en_EN": "All",
"label_fr_FR": "Tout"
},
"Searchprofile": {
"label_es_ES": "Perfil de búsqueda",
"label_it_IT": "Profilo di ricerca",
"label_en_EN": "Search profile",
"label_fr_FR": "Profil de recherche"
},
到目前为止,我所了解的:
import json
store_file = open( 'test.txt' , "w" )
with open('translations.json') as json_file:
data = json.load(json_file)
for label, translations in data.items():
for key in translations:
if key==('label_en_EN'):
json.dump(???, store_file)
.....'''