From 5d46f46a876147357923334bc9e9456d21d3cbd1 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sun, 23 Feb 2014 19:58:52 +0100 Subject: [PATCH] Script to automatically add a translation into all files. Syntax: addtr.py TR_GLOBAL_V "GLOBAL V." TR_GLOBAL_VARS --- radio/util/addtr.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 radio/util/addtr.py diff --git a/radio/util/addtr.py b/radio/util/addtr.py new file mode 100644 index 000000000..2c4a45858 --- /dev/null +++ b/radio/util/addtr.py @@ -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() +