Bug 90937 - Recognizing the language in join mode doesn't work as excepted
Summary: Recognizing the language in join mode doesn't work as excepted
Status: NEW
Alias: None
Product: ITS Tool
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Shaun McCance
QA Contact:
Depends on:
Reported: 2015-06-11 15:26 UTC by Miro Hrončok
Modified: 2015-06-16 14:29 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:

Try to get language code from PO header (2.03 KB, patch)
2015-06-16 14:29 UTC, Shaun McCance
Details | Splinter Review

Description Miro Hrončok 2015-06-11 15:26:38 UTC
Consider the following languages: cs, de

Consider the following piece of XML:

    <summary>The Programmers Solid 3D CAD Modeller</summary>

Consider the string used in the summary is only translated in cs and remains untranslated in de.

The following command:

    itstool -j file.xml.in -o file.xml locale/cs/LC_MESSAGES/openscad.mo locale/de/LC_MESSAGES/openscad.mo

Results in the same file as file.xml.in (no translations).

But when the following order is used instead:

    itstool -j file.xml.in -o file.xml locale/de/LC_MESSAGES/openscad.mo locale/cs/LC_MESSAGES/openscad.mo

It provides the following output:

    <summary>The Programmers Solid 3D CAD Modeller</summary>
    <summary xml:lang="openscad">Programátorův modelář pro 3D objekty</summary>

I would like to use this command:

    itstool -j file.xml.in -o file.xml locale/*/LC_MESSAGES/openscad.mo

But the language is always recognized as "openscad", because all the files are named openscad.mo. I also cannot use the -l option, because I'm using the asterisk symbol and I want all the languages to be there.

As a workaround, I can do this:

    for LANGCODE in ...; do
     mv locale/$LANGCODE/LC_MESSAGES/{openscad,$LANGCODE}.mo
    itstool -j file.xml.in -o file.xml ./locale/*/LC_MESSAGES/*.mo
    for LANGCODE in ...; do
     mv locale/$LANGCODE/LC_MESSAGES/{$LANGCODE,openscad}.mo

But I don't like it very much. Is there another solution? Should itstool somehow recognize the languge by the path of this kind? Maybe by giving it a clue with some switch?
Comment 1 Shaun McCance 2015-06-16 14:29:35 UTC
Created attachment 116534 [details] [review]
Try to get language code from PO header

I think the attached patch fixes this problem. Instead of relying only on the file name, it tries to get the language code from the Language field in the PO header.

I'll merge this to master shortly if there are no problems. I want to make sure it doesn't break anybody's build system. Please test if you're able.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.