File indexing completed on 2024-04-28 16:51:34
0001 #!/bin/env python3 0002 0003 import json 0004 import datetime 0005 import sys 0006 0007 if len(sys.argv) < 2: 0008 print ("Usage ./convertpottojson output_pot_file") 0009 sys.exit(-1) 0010 0011 potFileName = sys.argv[1] 0012 0013 jsonFilename = "./extension/_locales/en/messages.json" 0014 0015 outfile = open(potFileName, 'w') 0016 with open(jsonFilename, 'r') as infile: 0017 data = json.load(infile) 0018 0019 outfile.write('msgid ""\n') 0020 outfile.write('''msgstr "" 0021 "Project-Id-Version: PACKAGE VERSION\\n" 0022 "Report-Msgid-Bugs-To: https://bugs.kde.org\\n" 0023 "POT-Creation-Date: %s\\n" 0024 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n" 0025 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n" 0026 "Language-Team: LANGUAGE <kde-i18n-doc@kde.org>\\n" 0027 "Language: \\n" 0028 "MIME-Version: 1.0\\n" 0029 "Content-Type: text/plain; charset=UTF-8\\n" 0030 "Content-Transfer-Encoding: 8bit"\n\n''' % datetime.datetime.now()) 0031 0032 def writeEntry(key, value): 0033 value = value.replace('"', '\\\"') 0034 outfile.write('{0} "{1}"\n'.format(key, value)) 0035 0036 for msgid in data: 0037 msg = data[msgid] 0038 outfile.write('\n') 0039 outfile.write('#: %s:0\n' % msgid) 0040 0041 if "description" in msg: 0042 writeEntry('msgctxt', msg["description"]) 0043 writeEntry('msgid', msg["message"]) 0044 writeEntry('msgstr', '') 0045