Script to automatically add a translation into all files. Syntax:
addtr.py TR_GLOBAL_V "GLOBAL V." TR_GLOBAL_VARS
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#!/bin/env python
|
||||
|
||||
import sys, glob
|
||||
|
||||
string = sys.argv[1]
|
||||
translation = sys.argv[2]
|
||||
after = sys.argv[3]
|
||||
|
||||
def addLine(filename, newline):
|
||||
print filename, newline
|
||||
lines = file(filename, 'r').readlines()
|
||||
for i, line in enumerate(lines):
|
||||
if after in line:
|
||||
lines.insert(i+1, newline + '\n')
|
||||
break
|
||||
file(filename, 'w').writelines(lines)
|
||||
|
||||
def modifyTranslations():
|
||||
for filename in ['translations/en.h'] + glob.glob('translations/*.h.txt'):
|
||||
newline = "#define " + string + " "*(23-len(string)) + '"' + translation + '"'
|
||||
addLine(filename, newline)
|
||||
|
||||
def modifyDeclaration():
|
||||
newline = "extern const pm_char S" + string + "[];"
|
||||
filename = "translations.h"
|
||||
addLine(filename, newline)
|
||||
|
||||
def modifyDefinition():
|
||||
newline = "const pm_char S" + string + "[] PROGMEM = " + string + ";"
|
||||
filename = "translations.cpp"
|
||||
addLine(filename, newline)
|
||||
|
||||
modifyTranslations()
|
||||
modifyDeclaration()
|
||||
modifyDefinition()
|
||||
|
||||
Reference in New Issue
Block a user