PHP Localization Best Practices? gettext?

Posted by nute on Stack Overflow See other posts from Stack Overflow or by nute
Published on 2010-05-07T18:51:18Z Indexed on 2010/05/07 20:08 UTC
Read the original article Hit count: 488

We are in the process of making our website international, allowing multiple languages.

I've looked into php's "gettext" however, if I understand it right, I see a big flaw:

If my webpage has let's say "Hello World" as a static text. I can put the string as <?php echo gettext("Hello World"); ?>, generate the po/mo files using a tool. Then I would give the file to a translator to work on.

A few days later we want to change the text in English to say "Hello Small World"? Do I change the value in gettext? Do I create an english PO file and change it there? If you change the gettext it will consider it as a new string and you'll instantly loose the current translation ...

It seems to me that gradually, the content of the php file will have old text everywhere. Or people translating might have to be told "when you see Hello World, instead, translate Hello Small World".

I don't know I'm getting confused.

In other programming languages, I've seen that they use keywords such as web.home.featured.HelloWorld.

What is the best way to handle translations in PHP?

Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about internationalization