views:

173

answers:

2

i have a text "Translate text, webpage, or document "

which i need to translate into Japanese , the google translator

return the string as 翻訳テキスト、 Webページ、またはドキュメント

and when am writing that a text file the (ja.po) it looks like

–|–óƒeƒLƒXƒgA Webƒy[ƒWA‚Ü‚½‚̓hƒLƒ…ƒƒ“ƒg

what would be the error?

i am using poeditor.exe to view the file. am not using any encoding function at present.

for(/*extracting from the trnslated string array*/)
{
    $pattern = "/msgid \"".preg_quote($id, '/')."\"(\r?\n)msgstr \"\"/";
    $string = str_replace('"', '\"', $string);
    $replacement = "msgid \"$id\"\nmsgstr \"". $string . "\"";
    $res = preg_replace($pattern, $replacement, $con);
    $con = $res;
}
file_put_contents("ja.po", $con);
+1  A: 

It looks like the program you are using to read that file isn't understanding the encoding format that you wrote it out as. Are you using UTF8 all the way through? Maybe try http://www.php.net/manual/en/function.iconv.php to convert it to UTF8 if it is some other encoding.

Paul Tarjan
+1  A: 

How are you getting the string from Google and how are you writing it? Somewhere along the way it gets converted from UTF8 to latin1 I suppose. If you can figure out where it happens, use mb_convert_encoding to fix it.

BTW, the translated Japanese is pretty bad. ;)

deceze