Weather Applet: Weather desc. and weekdays not translatable

Bug #587123 reported by Gabor Karsay
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Awn Extras
Fix Released
Low
Gabor Karsay

Bug Description

The 2 variables DESCRIPTION and WEEKDAY are in the .po-files, but this only translates the name of the variable, not its content.

Tags: applet weather
Revision history for this message
Nicolas Delvaux (malizor) wrote :

Confirmed.

Changed in awn-extras:
status: New → Confirmed
Revision history for this message
Nicolas Delvaux (malizor) wrote :

I had a look at the source code and I compared trunk with the 0.2 branch (where Weather Applet translation is ok).
I found this file in 0.2 but not in 0.4: http://bazaar.launchpad.net/~awn-extras/awn-extras/0.3.2.2/annotate/head:/src/weather/weathertext.py

Notice the header of this file:
# mrooney: I am maintaining this file for now but it doesn't seem to be needed.
# the XML feed gives us a description already so the mapping below isn't necessary,
# and the gettext wrapping can be done in weather.py.

That's surely why it was removed from 0.4
But the current gettext wrapping in weather.py is useless (and I fail to understand how it is supposed to work).

Otherwise, a simple fix may be to import the "weathertext.py" from the 0.2 branch and to adapt the "forecast.py" file accordingly (copy-paste from "forecastdialog.py" from 0.2?)

Revision history for this message
Nicolas Delvaux (malizor) wrote :

This bug is fixed in my branch.
Now someone have to review it.

Changed in awn-extras:
assignee: nobody → Nicolas Delvaux (malaria)
onox (onox)
tags: added: applet weather
Revision history for this message
onox (onox) wrote :

See the review.

Changed in awn-extras:
assignee: Nicolas Delvaux (malaria) → onox (onox)
importance: Undecided → Low
Revision history for this message
Gabor Karsay (gabor-karsay) wrote :

This is another version of Nicolas Delvaux' patch. The file with the strings is now of ini-type. After applying the patch, a `intltool-update -p` is needed to update the .pot file. As I understand that is enough, launchpad automatically updates the .po files once the .pot template has been changed.

Revision history for this message
Michal Hruby (mhr3) wrote :

I agree with Gabor, it's fine (but not necessary) to regenerate the pot file, but please don't regenerate the po files, it makes merging translations from LP non-trivial. Also I don't like the extra i18n file that Gabor introduced, it should be defined in some of the .py files, otherwise people will only forget to update the file in the future.

Please use what is suggested on http://docs.python.org/library/gettext.html:

def N_(message): return message

animals = [N_('mollusk'),
           N_('albatross'),
           N_('rat'),
           N_('penguin'),
           N_('python'), ]

# ...
for a in animals:
    print _(a)

Revision history for this message
Nicolas Delvaux (malizor) wrote :

@Michal Hruby: are you sure that people will think more about those strings if they are lost in one of existing .py?
These are quite long already, an extra file with an explicit name seems better to me.

It can be named "weather-days-and-conditions" if you prefer.
It can be a .py too, so even if it is never executed we can hope that people will be curious enough to open it (if you thing that no-one may notice a simple "weather-i18n" file).

I'm waiting for a decision before updating my branch.

Revision history for this message
onox (onox) wrote :

I don't think I've gotten the hang of this gettext thingy yet, but the applet does:

condition_text = _(day["DESCRIPTION"])

So it's not like I extract the value of the data structure (animals in mhr3's example) somehow and then translates it (_(a) in example), so I'm not sure this gettext magic with N_ still works when you do something like _(some_value) where some_value happens to be equal to (for example) "python" instead of _(a) where a is one of the items in the data structure. The ini file seems fine to me.

Revision history for this message
Michal Hruby (mhr3) wrote :

I'd still prefer a py file, ini files have a section and *unique* keys in them, this blob just has a bunch of unnecessary "_translate" strings. Moreover intltool may get confused and try to translate the file as ini files are translated - by appending [langCode] to each of the keys and providing the translation.

Changed in awn-extras:
status: Confirmed → Fix Committed
onox (onox)
Changed in awn-extras:
milestone: none → 0.4.2
assignee: onox (onox) → Gabor Karsay (gabor-karsay)
Povilas Kanapickas (p12)
Changed in awn-extras:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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