[GRASS-SVN] r70921 - grass-addons/tools

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Apr 22 07:53:06 PDT 2017


Author: neteler
Date: 2017-04-22 07:53:06 -0700 (Sat, 22 Apr 2017)
New Revision: 70921

Modified:
   grass-addons/tools/transifex_merge.sh
Log:
transifex_merge.sh: added keeping of original po file headers

Modified: grass-addons/tools/transifex_merge.sh
===================================================================
--- grass-addons/tools/transifex_merge.sh	2017-04-22 14:08:21 UTC (rev 70920)
+++ grass-addons/tools/transifex_merge.sh	2017-04-22 14:53:06 UTC (rev 70921)
@@ -1,8 +1,8 @@
 #!/bin/bash
 
 # GRASS GIS transifex support script: fetches msg from transifex
-# Luca Delucchi 2017
-# based on gettext message merge procedure by Markus Neteler
+# Luca Delucchi 2017, based on gettext message merge procedure by Markus Neteler
+# - keep headers added by Markus Neteler
 
 # Required installation:
 # see
@@ -27,10 +27,12 @@
   exit 1;
 fi
 
+# fetch updated po from transifex server into local directory under transifex/.tx/
 tx pull -a
 
 cd ..
 
+# merge updated files into existing ones
 cd po
 NEWPODIR="../transifex/.tx/"
 NEWLIBPODIR="${NEWPODIR}grass72.grasslibspot/"
@@ -38,22 +40,40 @@
 for fil in `ls $NEWLIBPODIR`;
 do
   MYLANG=`echo $fil | rev | cut -c 13- | rev`
+  # fix undefined CHARSET in files pulled from transifex (grrr...)
   sed "s+charset=CHARSET+charset=UTF-8+g" ${NEWLIBPODIR}${MYLANG}_translation > ${NEWLIBPODIR}${MYLANG}_translation_new
   sed "s+charset=CHARSET+charset=UTF-8+g" ${NEWPODIR}grass72.grassmodspot/${MYLANG}_translation > ${NEWPODIR}grass72.grassmodspot/${MYLANG}_translation_new
   sed "s+charset=CHARSET+charset=UTF-8+g" ${NEWPODIR}grass72.grasswxpypot/${MYLANG}_translation > ${NEWPODIR}grass72.grasswxpypot/${MYLANG}_translation_new
+  
+  # https://www.gnu.org/software/gettext/manual/html_node/msgmerge-Invocation.html#msgmerge-Invocation
+  # if po file locally present, update it, otherwise copy over new file from transifex
   if [ -f grasslibs_${MYLANG}.po ]; then
-    $MSGMERGE ${NEWLIBPODIR}${MYLANG}_translation_new grasslibs_${MYLANG}.po -o grasslibs_${MYLANG}.po2 &&  mv grasslibs_${MYLANG}.po2 grasslibs_${MYLANG}.po
+    POFILE=grasslibs_${MYLANG}.po
+    grep -m1 -B555 '^$' $POFILE > grasslibs_${MYLANG}.header
+    msgcat --use-first --no-wrap grasslibs_${MYLANG}.header ${NEWLIBPODIR}${MYLANG}_translation_new > ${NEWLIBPODIR}${MYLANG}_translation_new.2
+    $MSGMERGE ${NEWLIBPODIR}${MYLANG}_translation_new.2 $POFILE -o $POFILE.2 &&  mv $POFILE.2 $POFILE && rm -f grasslibs_${MYLANG}.header
   else
+    # TODO: new file needs some header description!
     cp ${NEWLIBPODIR}${MYLANG}_translation_new grasslibs_${MYLANG}.po
   fi
+
   if [ -f grassmods_${MYLANG}.po ]; then
-    $MSGMERGE ${NEWPODIR}grass72.grassmodspot/${MYLANG}_translation_new grassmods_${MYLANG}.po -o grassmods_${MYLANG}.po2 &&  mv grassmods_${MYLANG}.po2 grassmods_${MYLANG}.po
+    POFILE=grassmods_${MYLANG}.po
+    grep -m1 -B555 '^$' $POFILE > grassmods_${MYLANG}.header
+    msgcat --use-first --no-wrap grassmods_${MYLANG}.header ${NEWPODIR}grass72.grassmodspot/${MYLANG}_translation_new > ${NEWPODIR}grass72.grassmodspot/${MYLANG}_translation_new.2
+    $MSGMERGE ${NEWPODIR}grass72.grassmodspot/${MYLANG}_translation_new.2 grassmods_${MYLANG}.po -o grassmods_${MYLANG}.po2 &&  mv grassmods_${MYLANG}.po2 grassmods_${MYLANG}.po && rm -f grassmods_${MYLANG}.header
   else
+    # TODO: new file needs some header description!
     cp ${NEWPODIR}grass72.grassmodspot/${MYLANG}_translation_new grassmods_${MYLANG}.po
   fi
+
   if [ -f grasswxpy_${MYLANG}.po ]; then
-    $MSGMERGE ${NEWPODIR}grass72.grasswxpypot/${MYLANG}_translation_new grasswxpy_${MYLANG}.po -o grasswxpy_${MYLANG}.po2 &&  mv grasswxpy_${MYLANG}.po2 grasswxpy_${MYLANG}.po
+    POFILE=grasswxpy_${MYLANG}.po
+    grep -m1 -B555 '^$' $POFILE > grasswxpy_${MYLANG}.header
+    msgcat --use-first --no-wrap grasswxpy_${MYLANG}.header ${NEWPODIR}grass72.grasswxpypot/${MYLANG}_translation_new > ${NEWPODIR}grass72.grasswxpypot/${MYLANG}_translation_new.2
+    $MSGMERGE ${NEWPODIR}grass72.grasswxpypot/${MYLANG}_translation_new.2 grasswxpy_${MYLANG}.po -o grasswxpy_${MYLANG}.po2 &&  mv grasswxpy_${MYLANG}.po2 grasswxpy_${MYLANG}.po && rm -f grasswxpy_${MYLANG}.header
   else
+    # TODO: new file needs some header description!
     cp ${NEWPODIR}grass72.grasswxpypot/${MYLANG}_translation_new grasswxpy_${MYLANG}.po
   fi
 done



More information about the grass-commit mailing list