How are .mo files generated?

Asked by Emilien Klein on 2010-12-31

I have been generating .pot translation template files using the "quickly package" command. The .pot file gets analyzed by Launchpad after each push, so they are available to translate. I have just downloaded the "fr.po" French translation file, and placed it inside the ./po/ folder where the .pot gets generated. I ran "quickly package" again, thinking that it would compile my .po in the .mo (as that is what I understand should happen, according to Didier's second answer to [1]), but that didn't happen. The .pot file got updated, but nothing else happened.

Question: Where should I place my .po files, and what command do I need to execute to get the .mo files compiled so that I can see my application translated using "quickly run"?

In my feature request asking for a command specifically supporting the translation workflows, "quickly translate" [2], I was making the assumption that the current situation was working. But now I'm lost and can't understand how to produce a translated app...

Thanks for your answer,
Emilien.

$quickly --version
Quickly 0.4.3
Ubuntu 10.04

[1] https://answers.launchpad.net/quickly/+question/92151
[2] https://bugs.launchpad.net/quickly/+bug/683342

Question information

Language:
English Edit question
Status:
Solved
For:
Quickly Edit question
Assignee:
No assignee Edit question
Solved by:
Michael Terry
Solved:
2011-01-04
Last query:
2011-01-04
Last reply:
2011-01-04
Michael Terry (mterry) said : #1

Try putting a LINGUAS file in po/ that contains a list of languages to use. For example, if you have French and Spanish translations, it could look like:

es
fr

Emilien Klein (emilien-klein) said : #2

Adding a LINGUAS file in ./po/ didn't work...

I also noted that Quickly itself [1] does not have such a file, how is it translated then?
[1] http://bazaar.launchpad.net/~quickly-committers/quickly/trunk/files/head:/po/

Best Michael Terry (mterry) said : #3

Ah, I apologize. LINGUAS file isn't necessary for Python projects.

When you do a 'quickly package', the .mo files will be generated and put into the deb package. If you really do want the files instead of just ensuring that they are built, you could manually run 'python setup.py build' which will put the .mo files in build/mo.

Emilien Klein (emilien-klein) said : #4

OK, `python setup.py build` created the .mo files in build/mo.
But when I run the application using `quickly run`, the application is not internationalized. The reason why I'm trying to generate the .mo files is to be able to verify that the translation is working fine (i.e. labels are not too small, etc.)

Is nobody verifying their application before generating the .deb? How can I do QA without having to create a package and install it each time I import my translations?

Can I create a symlink somewhere so that the .mo would be recognized?

Michael Terry (mterry) said : #5

The only way right now to do that is, as you say, create a package and install it. I opened bug 697281 about the feature request for 'quickly run'.

Didier Roche (didrocks) said : #6

Note that "quickly package" is just generating a deb, not doing a release, so it only affects you and you can test it locally.

Please, don't add that to "quickly run", we already discussed that in the past and it shouldn't be done as it will add slowliness (building is not a one second operation) making developing and testing with "quickly run" less productive and fun (in addition to the build errors)…

Emilien Klein (emilien-klein) said : #7

To summarize:
- The .mo files are compiled using `python setup.py build`, and generated in the ./build/mo folder. This folder is not recognized/looked for when running the application with `quickly run`, meaning that it is not possible to test the translations during the regular development flow
- The .mo files are automatically included in the .deb file created using `quickly package` (probable by calling `python setup.py build`, but it's not relevant to the discussion here), so it is possible to see the translations after having installed the package.

I am going to mark this question as solved, since I now know how those files are compiled.
Didier, I agree that `quickly run` should not compile the .mo files at each run (it would indeed be very time-consuming). Let's continue discussing this in the related opened bug #697281.

Emilien Klein (emilien-klein) said : #8

Thanks Michael Terry, that solved my question.