tags:

views:

201

answers:

1

When you call the gettext php function for translating text to another language, it uses the text you have on the page to act as the KEY/ID to lookup the value to replace it with

echo gettext('hello how are you today');

that would be the text used to lookup the translation, however I would like to use something like this

echo gettext('welcome_message');

and have that translated into English and any other language I offer. So how could I make this happen? How can I make gettext function ALWAYS use a language file? So if my default language is English for the site then instead of gettext showing welcome_message to an English user it would show hello how are you today

Is it as simple as just creating an English language file in addition to the other language files?

+2  A: 

You're on the right track. The string argument to gettext() is just an identifier, not a "default language". If there is no translation in the active locale, then gettext will return that identifier.

Your solution is just what you suspect: just create an English translation file.

timdev
great at first I was thinking it only looked for a language file and translated if the language set was a different language then the site was made it, Like if the site is in English and you are supposed to see spanish then it would get the spanish file but if you were English and viewing the site it would not even bother looking for an English language file but you are saying it will look for the English lang file first before showing the default identifier, awsome +1
jasondavis