Search code examples
phpinternationalizationgettextpoeditmachine-translation

Translating php app with gettext


From my previous questions about gettext, one of the biggest benefits of using PHP's gettext extension instead of other methods of language translation was that it is super easy to have other people make translation files with a program called Poedit.

Now I have gettext working in my app but I have not made any translation files yet, I found a demo file on the net and tested with it to conform my app works with gettext though.

Now I played around with poedit a little bit and I might be wrong, hopefully someone can clarify some issues.

  1. As far as I can tell poedit reads through your php code and finds all availabale spots to do a translation, is this correct?

  2. If the above is correct, then how do you have a human translator translate with poedit without having access to your app?

Or in simple terms is it possible to make a translation file with poedit without it having access to your php code?


Solution

  • Note that I have never used poedit myself, so this might not be totally accurate...

    An interesting article that you might first read, for some information : Localizing a WordPress Plugin Using poEdit. It's WordPress, which means PHP -- so the basic ideas should be OK for your application.

    Basically:

    • you first extract all the strings from the PHP source code
      • by telling poedit how your translation function is called
      • this should answer your 1)
    • then, you do translation
      • working with/on the .po file
      • And I'm guessing you can distribute this .po file to your translators, who can then translate the strings it contains
    • and, finally, you use the .po file to generate the .mo file that will be used in your application.

    This other article, about WordPress too, seems to indicate that I'm guessing right : User:Skippy/Creating POT Files -- especially, this sentence :

    Make the .po file available for download (or optionally include it in the plugin archive). Translators will use this file to construct a .mo file, which will be used by the load_plugin_textdomain() function.

    (Obviously, the function name you'll be using in your application will not be the same as the one in WordPress -- still, the idea is there).