I have a flutter project where I am trying the translation
feature as I am new to it. the code works for most of the files but only the below code have the issue where I am using a python
script to convert json
to arb
file. there is a script where arb
to json
is created and its working fine.
the beginning of both the file is same but this one gives error and other one runs fine...
below is the file
import json, glob, os, collections
from collections import OrderedDict
folder_path = 'lib/l10n/arb/'
json_folder_path = 'lib/l10n/json/'
for jsonFileName in glob.glob(os.path.join(json_folder_path, 'intl_*.json')):
with open(jsonFileName, 'r+') as json_file:
currentJson = json.load(json_file, object_pairs_hook=OrderedDict)
arbName = jsonFileName.split('/')[-1].replace('json','arb')
arbFileName = os.path.join(folder_path, arbName)
with open(arbFileName, 'r+') as arb_file:
currentArb = json.load(arb_file, object_pairs_hook=OrderedDict)
for item in currentJson:
currentArb[item] = currentJson[item]
arbString = json.dumps(currentArb, indent=2)
arb_file.seek(0)
arb_file.write(arbString)
arb_file.truncate()
error code:
scripts/localization/json_to_arb.py: line 1: import: command not found
from: can't read /var/mail/collections
scripts/localization/json_to_arb.py: line 4: folder_path: command not found
scripts/localization/json_to_arb.py: line 5: json_folder_path: command not found
scripts/localization/json_to_arb.py: line 7: syntax error near unexpected token `('
scripts/localization/json_to_arb.py: line 7: `for jsonFileName in glob.glob(os.path.join(json_folder_path, 'intl_*.json')):'