Support Android (XML) resource files for translation

Reported by pjv on 2008-09-27
24
This bug affects 3 people
Affects Status Importance Assigned to Milestone
APRSdroid
Won't Fix
Undecided
Georg Lukas
Launchpad itself
Low
Unassigned

Bug Description

Could it be possible to support translation from Android .xml files, next to .po? This is the only part of Launchpad for Android apps that is not working.

Information on Android: http://code.google.com/android
Docs on localization (more specifically bottom half): http://code.google.com/android/devel/resources-i18n.html

Most important here are the strings I suppose:
The hierarchic folder structure is:

MyApp/
    res/
        values-en/
            strings.xml
        values-fr/
            strings.xml

and an example of the contents of a strings.xml file is as follows:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Android's Fortune</string>
<string name="text_b_prefs">Preferences</string>
<string name="resources">Resources</string>
</resources>

As you can see it is actually very simple.

Related bugs are: #82137 and #68959 (some also xml)

It looks like a pretty bad system, when it comes to I18N. Why would they invent another bad system for localisation when there's already an existing good one (gettext) is beyond my comprehension.

It's beyond our ability to support everybody's hackish translation system. If this was actually a good system, I'd say it was worth supporting, but I just wonder how do you provide translations for plural form messages, for variable-containing messages, for providing comments/context to translators, etc?

The reference document even says that it's far from complete. If you have any say in what they do, just suggest them to use gettext to avoid reinventing the wheel. And the fact that this is their well-advertised platform only makes it worse.

I am marking this 'Won't fix' and I'd prefer if people provided separate tools to migrate these kind of files to PO files instead.

Changed in rosetta:
importance: Undecided → Wishlist
status: New → Won't Fix

I really don't know if Android translation system is bad or not. The real thing for me (subjective opinion) is that I would love to have Launchpad as a translation tool for Android applications. I use Launchpad for translation occasionally, and I must admit, I love it. It would be great if I can use it for some Android projects with sources in Launchpad. How is that going to be implemented, I have no clue. Will having some kind of strings.xml to .po translation tool help this integration?

pjv (pjv) wrote :

I made a wrapper, androidxml2po.bash, for the existing xml2po ("xml" here means Docbook xml), to automate some of the conversion. Very experimental. I wrote about it at http://groups.google.com/group/openintents/browse_thread/thread/84d7b059d0b15390?hl=en. I hope to test more soon and see if it really works and automates everything, also in practice. Any input is appreciated.

xml2po is not only DocBook. You can even provide custom "modes" altogether. "Automatic" mode that you are using in the script is not at all DocBook-related, and should work with any "correctly" (i.e. if you follow general recommendations of not putting content in attributes but only in tags as CDATA) formatted XML.

pjv (pjv) wrote :

 Данило, if you are better acquainted with xml2po, I could use your help in testing and improving my solution. I saw that there were multiple modes but at the moment it seems xml2po can parse the strings.xml just fine. It's just that Android uses multiple strings.xml's in different folders. This split is taken care of by my wrapper.

The only issue I can think of is that Launchpad (and .po in general) requires us to put the English original string in msgid. This enforces that the English strings in strings.xml need to be unique: there should be no repeats. On the other hand it seems Android does not enforce this. In fact you might even want to do it as the same string in English is not necessarily the same string in another language. An example: "work" (the verb) and "work" (the noun), in French "travailler" and "travail". A solution would be to use the identifier that is in "name" in strings.xml, but then Launchpad Rosetta does not have an original English text to display. I am not an expert in localization so I have no idea how this is usually solved/done.

Also, how do we deal with projects that consist of multiple Android projects, and therefore have multiple res folders? Would the .pot files would need to be concatenated somehow or can we upload multiple .pot files to Launchpad?

Kind regards,

The proper solution is to use "message context": msgctxt feature in PO files. Unfortunately, xml2po doesn't support that yet, but I'll consider adding it in the future (fwiw, xml2po is part of gnome-doc-utils, so if you want to track changes there, that's where you'd have to do it).

As far as handling multiple files, with xml2po you can simply pass several XML files on the command line (i.e. even *.xml).

Georg Lukas (ge0rg) wrote :

Sorry, I should have read the whole report history before clicking the "me too" button! *:)

Changed in aprsdroid:
assignee: nobody → Ge0rG (georg-op-co)
status: New → Won't Fix
Emilien Klein (emilien-klein) wrote :

I have reported a new bug against Android to ask support for gettext translation formats. Please go there and star the issue so that we can maybe get Android apps to produce .pot files in the future: http://code.google.com/p/android/issues/detail?id=11005

Emilien Klein (emilien-klein) wrote :

This is an answer from Google on the issue I opened against Android (see previous post):

========
Comment 3 by project member <email address hidden>, Sep 08 (5 days ago)

We've been thinking about this actually. No promises though.

We would definitively accept contributions on this though.
========

If anybody wants to help Google support some way of exporting Android translations to gettext format, please get in touch with them through the previously cited issue url.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.