]> git.deb.at Git - deb/packages.git/blobdiff - bin/convert_po_to_utf8
Convert all .po files to UTF-8
[deb/packages.git] / bin / convert_po_to_utf8
diff --git a/bin/convert_po_to_utf8 b/bin/convert_po_to_utf8
new file mode 100755 (executable)
index 0000000..c6f74ba
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+set -e
+
+pofile=$1
+charset=$(perl -n -e 's/^.*charset=([\w-]+).*$/uc($1)/e && print' "$pofile")
+
+echo pofile=$pofile charset=$charset
+
+if [ "$charset" = "UTF-8" ]
+then
+    echo >&2 charset is already utf-8
+    exit 1
+fi
+
+set -x
+
+iconv -f $charset -t utf-8 "$pofile" >"$pofile".tmp
+perl -p -e 's/charset=([\w-]+)/charset=UTF-8/' "$pofile".tmp >"$pofile"
+rm -f "$pofile".tmp