Reputation: 343
I'm using gettext to write a multilingual php web app.
Whats the best way of actually using gettext, I can use it as a key phrase:
echo (_("main.welcomeText.1"));
Or
echo (_("Welcome to my site, we build great webapps."));
In both ways I use a .po file to translate the request ofcourse.
Whats the better way ?
Upvotes: 2
Views: 190
Reputation: 557
It depends :):
The best taught way is main.welcomText.1 because:
using "Welcome to my site, we build great webapps." make it easier to read and for translator to translate but is less easier to correct/debug especially if it's a lot of time in the code
So keys are used for debugging, so they should be easier to find where in your code they are.
EDIT: Provide the base English translation ie:
main.welcomeText.1:Welcome to my site, we build great webapps.
This is more work for the developer in short term. But few in large project :)
Upvotes: 2
Reputation: 8616
I have never used gettext... and never really known anyone who has.
I would suggest a different approach, that is to use Smarty/Dwoo to separate presentation totally. Using this you can then have very simple config/language files to do internationalisation.
Upvotes: 0