Differences between .po and .pot.... how to get my first template up?

Asked by Dean Jansen on 2010-02-10

I've been using the GUI app POedit to scan some php code and extract strings, but the program only seems to create a .po file and not a .pot file. Is there an easy way to convert? If I upload the .po file as en.po, will that work as a base template for launchpad?

Also, are there any naming conventions for the .pot file? I tried to figure it out via the help document, but found it relatively confusing.

Thanks in advance.

Question information

Language:
English Edit question
Status:
Answered
For:
Launchpad itself Edit question
Assignee:
No assignee Edit question
Last query:
2010-02-10
Last reply:
2010-05-06
Henning Eggers (henninge) said : #1

Renaming your 'en.po' to 'translationdomain.pot' creates the PO template (replace 'translationdomain' with your actual domain). That's it. A PO template is a PO file without any translations filled in.

It would be interesting to know what you found confusing about the documentation as we have been putting effort into making it as clear as possible. We probably assume that you are familiar with the gettext documentation at http://www.gnu.org/software/gettext/manual/gettext.html . This explains about creating templates and po files from templates in sections 5 and 6. Obviously, Launchpad and other tools replace a lot of the manual steps described there but it is good to know where it all comes from.

If possible, please follow the recommentation on the help pages to import your template (and possible existing translations) from a Bazaar branch. Please note that branches can be imported from other VCS, too.

Henning

Henning Eggers (henninge) said : #2

I just added this bit to our documentation:
https://help.launchpad.net/Translations/POTemplates

Dean Jansen (list) said : #3

Hey Henning,

Really appreciate your time and help here.

The main problem is that I'm slightly less command line inclined than most people here, so I perused the gettext man files and opted to use poedit (a gui) which is a very inflexible program. It wasn't clear what the exact differences between .po and .pot was, but I suspected that one could be created from the other.

I think the extra documentation will help others in a similar situation, but it wasn't clear to me that translationdomain.pot was supposed to be mydomain.pot (until you said so).

For my domain, would it be makeinternettv.org.pot or can I leave the .org out?

Thanks,
Dean

Pabjvar (pabjvar) said : #4

Hi Henning,

  Thanks for you response... I've been having the same questions...

thanks,
pablo

Henning Eggers (henninge) said : #5

I wrote up an FAQ entry about translation domains and template names. Hope that helps.

Henning Eggers suggests this article as an answer to your question:
FAQ #955: “What do I choose for a translation domain and template name?”.

fisharebest (fisharebest) said : #6

The FAQ doesn't answer the question at all. It doesn't tell me what to choose and doesn't tell me how to choose.

It tells me what it isn't (a domain name).

It tells me what is shouldn't contain (version numbers).

It tells me that it should be defined in the source code (it isn't)

This seems to be a launchpad/rosetta specific concept. None of our 20 developers has heard of "translation domain".

We have a directory containing project-name.pot, and 30 pairs of en.po/en.mo, fr.po/fr.mo etc.

Is the domain just the project name, or is it the project build? the project release? do I need a separate domain for each module in the project? Do I need one per language?

What is a translation domain actually used for? I guess it is more than just the project name - otherwise you'd use the project name!

Can I use accented letters, or just plain ascii? Max length? Min length? Does it have to be unique within launchpad, or just unique within my project?

Actual example(s) would be helpful.

David Planella (dpm) said : #7

El dj 11 de 03 de 2010 a les 16:37 +0000, en/na fisharebest va escriure:
> Question #100519 on Launchpad Translations changed:
> https://answers.launchpad.net/rosetta/+question/100519
>
> fisharebest posted a new comment:
> The FAQ doesn't answer the question at all. It doesn't tell me what to
> choose and doesn't tell me how to choose.
>
> It tells me what it isn't (a domain name).
>
> It tells me what is shouldn't contain (version numbers).
>
> It tells me that it should be defined in the source code (it isn't)
>
> This seems to be a launchpad/rosetta specific concept. None of our 20
> developers has heard of "translation domain".
>

This is not Launchpad-specific. Launchpad Translations builds upon the
widely used Gettext infrastructure, from which the "domain" nomenclature
comes from. See below for a more detailed explanation. You can also
consult the gettext manual:

  http://www.gnu.org/software/gettext/manual/gettext.html

> We have a directory containing project-name.pot, and 30 pairs of
> en.po/en.mo, fr.po/fr.mo etc.
>

Generally, you'll have a translation template (POT file) in the same
directory as the translations (PO files). The layout in the code
generally looks like:

templatedir/template.pot <- Translation template
templatedir/ca.po <- PO file for a language (e.g. Catalan)
templatedir/de.po <- PO file for a language (e.g. German)
...

A lot of Open Source projects have standardized in naming 'templatedir'
as 'po', but that's just a convention and up to the developer to follow
it or not.

If you've got more than one template, you can simply continue with the
same layout:

templatedir1/template1.pot
templatedir2/template2.pot
...

As a developer, you'll have to take care of generating a POT file and
announcing to translators that your project is ready for translation.
Then translators (or Launchpad), will take care to give you the PO files
for each language, for which they'll use the English POT file as a
basis.

Once you've got all translations, you'll build your project and your
build infrastructure will take care of generating a binary .mo file for
each of the .po files in the source. At installation time, these files
will be put into the directories gettext expects them to be to pick up
the translations and load them in the UI.

> Is the domain just the project name, or is it the project build?

Most projects have only got one template and domain, in which case it is
a convention to use the same name for the project, template and domain.

> the
> project release? do I need a separate domain for each module in the
> project?

You'll need a domain per template, but as I say, most projects just use
one template (which actually makes life easier for translators).

> Do I need one per language?
>

No, domain and number of languages are unrelated.

> What is a translation domain actually used for? I guess it is more than
> just the project name - otherwise you'd use the project name!
>

The domain name is used by gettext to locate the binary catalogs
(the .mo files created on build from the .po files) installed in the
system.

You'll find more info here:

  https://wiki.ubuntu.com/UbuntuDevelopment/Internationalisation/Glossary#TranslationDomain

> Can I use accented letters, or just plain ascii? Max length? Min
> length?

As it also needs to be specified in the code, often in C sources, I'd
recommend using plain ASCII. Min length: I don't think there is one
(well, probably 1 char). Max length: looking at the bindtextdomain
gettext function, it's a char, so it will vary depending on your
architecture. In any case, I don't think you'll ever need all characters
you can fit in a char.

The rule of thumb is to use a descriptive name that is unique in the
system where you'll be installing the program. This will simply be the
project's name in most cases.

> Does it have to be unique within launchpad, or just unique
> within my project?
>

It needs to be unique in the system where you'll be installing your
project.

I hope this helps.

Regards,
David.

fisharebest (fisharebest) said : #8

David, thanks for replying.

My current directory structure is

language/my_project.pot
language/en.po
language/en.mo
language/fr.po
language/fr.mo
language/de.po
language/de.mo
etc.

In the code (written in PHP, using bits of the Zend_Framework), we have just one line which makes everything work.

$translate=new Zend_Translate('gettext', 'language/', $locale, array('scan'=>Zend_Translate::LOCALE_FILENAME));

We don't have/use/specify/reference/mention a "domain" anywhere.

Does this mean that my directory structure is not compatible with launchpad/rosetta, and that I need to restructure it so that the locale is a directory name, rather than a file name. e.g.

/langauge/my_project.pot
/language/en/LC_MESSAGES/my_project.po
/language/en/LC_MESSAGES/my_project.mo
/language/fr/LC_MESSAGES/my_project.po
/language/fr/LC_MESSAGES/my_project.mo
/language/de/LC_MESSAGES/my_project.po
/language/de/LC_MESSAGES/my_project.mo

This way, my project name now becomes the domain name?

I'd prefer to keep my existing (simple!) structure. Is this possible?

<<Most projects have only got one template and domain, in which case it is
a convention to use the same name for the project, template and domain.>>

Ah - this could be the most helpful thing I've read so far! Perhaps add this sentence to the FAQ?

David Planella (dpm) said : #9

I'm not sure if you are still looking for an answer, but your directory structure (one POT file, a PO file per language, everything in the same dir) seems just fine. It's the same I mentioned on my previous reply and the one recommended in the import policy in Launchpad:

https://help.launchpad.net/Translations/YourProject/ImportPolicy

fisharebest (fisharebest) said : #10

David, thanks for the confirmation.

For the benefit of anyone else reading this far, my current "simple" structure (described above) worked just fine.

I upload a tarball containing the contents of my language directory.

When I download a tarball of .MO files, they are renamed to this format

xx/LC_MESSAGES/my_project.mo

so my build/release script needs to extract/rename them. No big problem.

Similary, when I download the .PO files (some of my translators like to work offline), they are renamed to my_project/my_project-xx.po

I rename these back to xx.po before I re-upload them, but I am not sure if this is necessary.

David Planella (dpm) said : #11

El dj 06 de 05 de 2010 a les 13:07 +0000, en/na fisharebest va escriure:
> Question #100519 on Launchpad Translations changed:
> https://answers.edge.launchpad.net/rosetta/+question/100519
>
> fisharebest posted a new comment:
> David, thanks for the confirmation.
>

Glad it was useful :)

> For the benefit of anyone else reading this far, my current "simple"
> structure (described above) worked just fine.
>
> I upload a tarball containing the contents of my language directory.
>
> When I download a tarball of .MO files, they are renamed to this format
>
> xx/LC_MESSAGES/my_project.mo
>

Why do you download the .mo files? Can your build system not create them
from the source files? It would make life a lot easier for you, saving
you the need for downloading them.

> so my build/release script needs to extract/rename them. No big
> problem.
>
> Similary, when I download the .PO files (some of my translators like to
> work offline), they are renamed to my_project/my_project-xx.po
>

That's right, that's because of this bug
https://bugs.launchpad.net/rosetta/+bug/148286

I think though, your directory layout would allow you to use automatic
imports and exports from bzr branches (i.e. translations are exported
directly from the branch and committed automatically for you), working
around this bug. If you are using Launchpad for development, that is
easy, as you'll already have a bzr branch. If your project is hosted
elsewhere, you can still mirror the external branches in Launchpad to
use this functionality.

      * Automatic imports: http://is.gd/bWTnf
      * Automatic exports: http://is.gd/bWTqN

Unrelated to this, why do you download the files for translators? Why
don't they just download them themselves directly from Launchpad?

Note that I'm not saying that this is wrong, I'm just trying to help
suggesting an easier workflow for you as the maintainer.

> I rename these back to xx.po before I re-upload them, but I am not sure
> if this is necessary.
>

What you are doing here is correct, as far as I know.

fisharebest (fisharebest) said : #12

<<Why do you download the .mo files? Can your build system not create them from the source files?>>

I can either

download the .MO files, and include them directly in a build

or

download the .PO files, check them in to my SVN server, compile them, and then include them in a build

Downloading the .MO files is just quicker and easier. FYI, the project generates a "snapshot" build most nights. For an official release, I would compile the .PO files.

<<If your project is hosted elsewhere, you can still mirror the external branches in Launchpad to use this functionality.>>

I would *really* like to use this feature - but it only works for publicly accessible SVN servers. My project's SVN server requires a username/password - even for read-only access. The "mirror external repository" function does not let me specify a username/password. BTW - this is not for privacy reasons - until we find a permanent home for it, the SVN server is at my house, and my internet connection has limited bandwidth.

The project's developers discussed moving to BZR. None of them wanted to lean a new set of terminology/concepts/commands/procedures. There are also very few GUI clients available, and none for MacOS. We have a SVN server, it works, and we know how to use it.....

It may be possible to keep our language files in BZR on launchpad and our source code in SVN? I just haven't had time to read any BZR tutorials.

<<Unrelated to this, why do you download the files for translators? Why don't they just download them themselves directly from Launchpad?>>

They do. I said "I". I meant "we". Sorry.

PS - I hope I don't sound critical. Everyone on the project thinks that the launchpad translation system is brilliant!

Can you help with this problem?

Provide an answer of your own, or ask Dean Jansen for more information if necessary.

To post a message you must log in.