gettext()_ and the equivalent wordpress __() functions will all return the string you call with if there is no translation found.

A common thought is can I use a key / token in place of the source text so that my code never needs to change and just the translations get edited. Well, yes you can but there are some considerations:

  • If no translation is found then you will get the key/token returned. There is no way round this, although you could create your own function call (or trap the wordpress gettext() ) and perform a default to the base language translation yourself if you wanted to.
  • If you really want to use a key/token then just ensure all the languages have a translation evern if it involves copying the base language translation for now.
  • Remember many languages are really different to English with very different word ordering and string lengths – having correct translations is really important to stop a site looking wrong for other language users.
  • Lots and lots of developers will tell you just don’t do it, translate the base language translation for typo correction or minor edits, but rely on changing the text in code to cause translations to be required so that you don’t get in a situation of there being bad translations of changed text. As some put it: “the gettext() developers know what they are doing – get over it and do it their way”!
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.


Your email address will not be published.