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 ?
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 🙂