Translating with strtr in PHP fails when mixing placeholders and japanese

80 views Asked by At

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?

1

There are 1 answers

3
Francisco Moreno On BEST ANSWER

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

Pay attention to % sign!