views:

399

answers:

2

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?

A: 

Hi,

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 informations : Localizing a WordPress Plugin Using poEdit
It's wordpress, which means PHP -- so the basic ideas should be OK for your application.

Basically, if I understand well :

  • 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)


Hope this helps :-)
Have fun !

Pascal MARTIN
thanks, you always put in so much effort into your answers +1
jasondavis
@jason : you're welcome :-) Here, I was curious about gettext : I suppose I'll be using it one day or another (especially as I'm currently working on a project that uses gettext -- even if I'm not the one responsible for the translation stuff)
Pascal MARTIN
I was hoping there was a way to create the original (first) fiel that gettext will use by hand in a text editor but it is looking like I will have to let poedit scan all my project files unless I find another method
jasondavis
It would seem that .po files are just text files, with a special format (see http://en.wikipedia.org/wiki/GNU_gettext#Translating for a real basic example) ;; maybe you can find the definition of that format somewhere ? considering gettext is GNU, the format has to be open...
Pascal MARTIN
Here http://stackoverflow.com/questions/873017/poedit-workaround-for-dynamic-gettext is the main reason I would like to do it manually as I see a problem in the way it works, thanks for the link
jasondavis
oh, I see -- but what about the solution proposed by raspi on that page ? http://stackoverflow.com/questions/873017/poedit-workaround-for-dynamic-gettext/874428#874428
Pascal MARTIN
well my case is a little different, To use gettext you have to call the gettext or else _() as far as I know, well on my app I will be using a custom named function adn then that function will call the gettext function, so poedit will only see the actual gettext or _() called 1 time in the whole site inside of a function because poedit doesn't execute code, just reads files. I just successfuly was able to edit a .po file in a text editor and have gettext read it correctly though =)
jasondavis
I should of read your wordpress link first, it appears poedit has a tab "keywords" when making a new project, you can enter in a custom function name there, this is great
jasondavis
Reading your first comment, I was going to say "why don't you indicate that your translation function is called 'adn'", and then I saw you found out yourself -- nice :-)
Pascal MARTIN
@downvoter : I'm OK to be downvoted *(it's the way SO works ; even if being downvoted 4 months after my answer was accepted seems strange)*, but explaining what you find wrong in my answer might help *(both me, the OP, and the SO community as a whole)* : it would allow me to edit my answer, to enhance it :-) ;; Thanks in advance :-)
Pascal MARTIN
+1  A: 

No, poEdit doesn't read all your sources. You use the gettext utility "xgettext" to do that.

Basically, xgettext will produce a .po file.

Your translators will use POEdit to work on that .po file.

When the translater is done, you'll compile the .po into an .mo, which you app will use to look up translations.

If you have gettext installed on some unixy system, try "info gettext" in bash.

timdev
@tim : the http://www.poedit.net/ page says : "You can use Poedit to scan source code for translatable strings." -- so it would seem you can use poEdit to read the source code ?
Pascal MARTIN
Oh, look at that! Haven't actually used gettext in a long time (it scarred me). Back then, i ended up scripting some stuff on the command-line to drive xgettext, and it worked well enough. I think the php-gettext extension had some decent-enough docs on the process..
timdev