Search code examples
bashgettextxgettext

Charset problem with xgettext & msgmerge


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


Solution

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