PTotD

… also known as Python Tip of the Day:

What’s wrong (translation-wise) on this snippet of python code?

random = _("Lorem ipsum dolor sit amet, " +
           "consectetur adipisicing elit")

You are not going to see any warning on your code, if you don’t have this message translated you will never notice…

But unfortunately, as soon as you have this message translated you will notice that only half of the string is translated, which for Arabic or other RTL ((Right to Left)) languages can be quite funny…

So, you already noticed right?

Turns out that gettext gets confused by the plus sign! As you already may remember by now, Python can join multiple strings just by putting them together, no need for a plus sign. Try it yourself on your python console:

>>> print ("Lorem " " ipsum" " dolor"
... " amet")
Lorem  ipsum dolor amet

So dear Python developers out there, pretty please double check your strings marked for translation, if not a translator will find out, hopefully before a release, and report it back :)

Planet GNOME

Seems that I pestered enough our (that sound good!) planet editor ((Wo was so nice to also create my planet hackergotchi!)) that he finally added me in. Hi GNOMEr’s around the globe!!

I’m Gil Forcada, Coordinator of the Catalan Translator Team, member of the Localization Coordination Team, nowadays also Damned-Lies maintainer and usually you see me on GUADEC’s behind the info desk :D

I’m all digital ears to digitally hear anything related to l10n/i18n and how to move GTP ((GNOME Translation Project)) forward!

Edit: fixed the \ on the second code snippet (no need for that) and the LTR to RTL! Oh my!

7 pensaments quant a “PTotD”

  1. Python tip of the day:

    When in open parenthesis, bracket or brace, don’t use \ for line continuation. It’s superfluous and ugly :)

  2. Heya Gil :)

    I’ll +1 on what Patryk has said. FWIW, the style you are using is usually referred to as the C-style string continuation, and xgettext, being originally designed for C, supports it very well.

    Cheers,
    Danilo

  3. Thanks Patryk and Yo’av, both of them are fixed. Quite shameful the LTR one … :$

  4. pygettext.py from python-tools-2.7.3-7.2.fc17.x86_64 complains about this case:


    $ pygettext.py myapplication.py
    *** myapplication.py:9: Seen unexpected token "+"

  5. P.S. Maybe it’s because I’m a gettext newbie, but the article wasn’t very clear. For a moment I thought that the code is broken and I was wondering how can the gettext.gettext function (aliased as _) be affected by how its parameter is constructed. I had to do a little experiment to figure out that you were actually talking about the generation of the message catalog. Perhaps you should have been more explicit about what’s going on.

  6. I suffer from chronic migraines and have tried numerous medications with insignificant success. A friend recommended CBD, so I clear to present it a try. I was amazed at how right away it helped to alleviate my migraine wretchedness and nausea. I now https://www.cornbreadhemp.com/collections/full-spectrum-cbd-oil buying CBD grease regularly as a preventative limitation, and include noticed a relevant decrease in the frequency and hardness of my migraines. I greatly praise CBD in support of anyone looking for a natural alternate to stock migraine medications.

Els comentaris estan tancats.