phptranslationstrtr

Translating with strtr in PHP fails when mixing placeholders and japanese


I'm using strtr to make translations and since I started using Japanese, it fails to replace placeholders.

Here is an example string:

%service% で入力してください

If I just run the code below, it will not replace %service% placeholder:

strtr("%service% で入力してください", array("%service%" => "Facebook"));

Result: %Service% で入力してください

But if I do it in many other languages, it simply work. Eg: %service% connect becomes Facebook connect

Anyone know a workaround to that?


Solution

  • That's because %service% does not equal %service%.

    Pay attention to % sign!