3 from __future__
import print_function
9 def addLine(filename
, newline
, after
):
10 print(filename
, newline
)
11 with
open(filename
, 'r') as f
:
13 for i
, line
in enumerate(lines
):
15 lines
.insert(i
+ 1, newline
+ '\n')
17 with
open(filename
, 'w') as f
:
21 def modifyTranslations(constant
, translation
, after
):
22 for filename
in glob
.glob('translations/*.h.txt'):
23 newline
= "#define " + constant
+ " " * max(1, 31 - len(constant
)) + '"' + translation
+ '"'
24 addLine(filename
, newline
, after
+ " ")
27 def modifyDeclaration(constant
, after
):
28 newline
= "extern const char S" + constant
+ "[];"
29 filename
= "translations.h"
30 addLine(filename
, newline
, after
+ "[];")
33 def modifyDefinition(constant
, after
):
34 newline
= "const char S" + constant
+ "[] = " + constant
+ ";"
35 filename
= "translations.cpp"
36 addLine(filename
, newline
, after
+ "[] ")
40 for arg
in sys
.argv
[1:-1]:
41 constant
, translation
= arg
.split("=")
42 modifyTranslations(constant
, translation
, after
)
43 modifyDeclaration(constant
, after
)
44 modifyDefinition(constant
, after
)