1

I'm trying to make a script to create a .po files from my sources files & merge it with the existing one so I don't have to redo the translation every time I update my website.

I'm basing my script on this blog post http://www.lxg.de/code/playing-with-xgettext

Here is what I'm trying to run :

#!/bin/bash
if [ $# -eq 1 ]
then
    if [ -d "./locale/$1" ]
    then
        echo '' > "./locale/$1/msg_tmp.po"
        find . -type f -iname "*.php" | xgettext -j --from-code="utf-8" -o "./locale/$1/msg_tmp.po" -f -
        msgmerge -N "./locale/$1/msg.po" "./locale/$1/msg_tmp_iconv.po" > "./locale/$1/msg_new.po"
        mv "./locale/$1/msg_new.po" "./locale/$1/msg.po"
        rm "./locale/$1/msg_tmp.po"
        rm "./locale/$1/msg_tmp_iconv.po"
    else
        echo The directory locale/$1 does not exist
    fi
else
    echo Locale not specified
fi

The problem is with the msgmerge command, It complains about non ascii strings & invalid multibyte sequence.

thanks for any help

Paté
  • 1,914
  • 2
  • 22
  • 33

1 Answers1

4

Your translator forgot to fill in the Content-Type header properly.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • 1
    I have a similar issue now, I use xgettext in cmd to write a `.po` file but the header prints `charset=CHARSET` instead of `UTF-8´ although I use in my call `--from-code=UTF-8` is there a way to adjust the header without having to use File I/O, some xgettext extension to adjust the header ? – Hadi Farah Sep 27 '18 at 11:37
  • You can use `sed -i 's/charset=CHARSET/charset=UTF-8/g' yourdomain.po` to convert the PO files' charset. – Koala Yeung Nov 17 '18 at 03:17