moving to core/
[debian/openrocket] / core / scripts / renameTranslationKeys.sh
diff --git a/core/scripts/renameTranslationKeys.sh b/core/scripts/renameTranslationKeys.sh
new file mode 100644 (file)
index 0000000..2a7314d
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+#
+# Rename translation keys in translation files.
+#
+# Usage:
+#    renameTranslationKeys.sh <mapping files...>
+#
+# The mapping files contain "<original> <new>" key pairs.
+# Empty lines and lines starting with "#" are ignored.
+# All translation files are modified at once.
+#
+
+TRANSLATIONS=messages*.properties
+
+cat "$@" | while read line; do
+
+    if echo "$line" | grep -q "^\s*$\|^\s*#"; then
+       continue
+    fi
+
+    if ! echo "$line" | egrep -q "^\s*[a-zA-Z0-9._-]+\s+[a-zA-Z0-9._-]+\s*$"; then
+       echo "Invalid line:  $line"
+    fi
+
+    from="`echo $line | cut -d" " -f1`"
+    to="`echo $line | cut -d" " -f2`"
+
+    sed -i "s/^${from}\s*=\s*/${to} = /" $TRANSLATIONS
+
+done