Browse Source

Created 1 time use php converter

+ RIght change

Usage:
./hst_convert_php2po.sh de
Jaap Marcus 5 years ago
parent
commit
96d65003c1
2 changed files with 45 additions and 0 deletions
  1. 45 0
      web/locale/hst_convert_php2po.sh
  2. 0 0
      web/locale/hst_convert_po2mo.sh

+ 45 - 0
web/locale/hst_convert_php2po.sh

@@ -0,0 +1,45 @@
+#!/bin/bash
+if [ ! -e /usr/bin/xgettext ]; then 
+    echo " **********************************************************"
+    echo " * Unable to find xgettext please install gettext package *"
+    echo " **********************************************************"
+    exit 3;
+fi
+
+lang=${1}
+
+if [ -z $lang ]; then 
+    echo "No Language defined"
+    exit 3;
+fi
+
+# Tempory delete the old file just for testing 
+rm -f -r ./$lang
+
+if [ ! -d ./$lang/LC_MESSAGES/ ]; then 
+    mkdir ./$lang/
+    mkdir ./$lang/LC_MESSAGES/
+    
+    msginit -i ./hestiacp.pot --locale=$lang --no-translator
+    mv ./$lang.po ./$lang/LC_MESSAGES/hestiacp.po;
+fi
+
+if [ -e ../inc/i18n/$lang.php ]; then 
+    while read f
+    do
+        b=$(echo "$f" |cut -f 2 -d \');
+        c=$(echo "$f" |cut -f 4 -d \');
+        if [ ! -z "$c" ]; then 
+            c=$(echo $c | sed -e 's/\"/\\\"/g');
+            #c=$(echo $c | sed -e 's/\\/\\\\/g');
+            echo "$b -> $c"
+            # locate b in msgid  and replace the next line 
+            #echo "msgid \"$b\"";
+            sed -i "/msgid \"$b\"/{n;s/msgstr \".*\"/msgstr \"$c\"/}" ./$lang/LC_MESSAGES/hestiacp.po
+
+            
+#            rm ./$lang/LC_MESSAGES/hestiacp.po
+#            mv ./$lang/LC_MESSAGES/hestiacp.po.bak ./$lang/LC_MESSAGES/hestiacp.po
+        fi
+    done <  ../inc/i18n/$lang.php
+fi

+ 0 - 0
web/locale/hst_convert_po2mo.sh