Skip to content

Instantly share code, notes, and snippets.

@perpouh
Created January 15, 2020 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perpouh/894e20ccba5c9988e38af5c93f2ce517 to your computer and use it in GitHub Desktop.
Save perpouh/894e20ccba5c9988e38af5c93f2ce517 to your computer and use it in GitHub Desktop.
CSVを読みながらi18nファイルを吐き出す
import csv
header = '''
export default {
ja: {
'''
footer = '''
}
}
'''
of = open('./TranslationsJa.js', 'w')
of.write(header)
with open('message.csv') as inf:
reader = csv.reader(inf)
for row in reader:
of.write(f"'{row[2]}': '{row[1]}',\n")
of.write(footer)
of.close()
@perpouh
Copy link
Author

perpouh commented Jan 15, 2020

コマンドライン引数でどうこうとかはしていない

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment