Re: Code freeze break for Hamster



Ok, so managed to get to ugettext. Final patch is to use
gettext.install and specifying to always use unicode instead of doing
the _ assignment manually:


Index: hamster/__init__.py
===================================================================
--- hamster/__init__.py	(revision 829)
+++ hamster/__init__.py	(working copy)
@@ -34,8 +34,7 @@
 from dispatcher import Dispatcher

 # Init i18n
-import __builtin__
-__builtin__._ = gettext.gettext
+gettext.install("hamster-applet", unicode = True)

 # Allow to use not installed hamster
 UNINSTALLED_HAMSTER = False




===========================
This approach also solves the problem.
Did not touch anything else because it doesn't break the code.
Patch has been successfully tested on OpenSUSE 11.1 (python 2.6) and
Ubuntu Intrepid (python 2.4)

Let me know what you think,
Thanks!

Toms


On Thu, Mar 12, 2009 at 7:37 PM, Toms <toms baugis gmail com> wrote:
> On Thu, Mar 12, 2009 at 7:26 PM, Andre Klapper <ak-47 gmx net> wrote:
> ..
>>> -            work_cat_id = self.__add_category(_(work_category["name"]))
>>> +            work_cat_id = self.__add_category(unicode(work_category["name"]))
>>> -            nonwork_cat_id = self.__add_category(_(nonwork_category["name"]))
>>> +            nonwork_cat_id = self.__add_category(unicode(nonwork_category["name"]))
>>
>> The last two codelines remove the translation marker for "name" so it
>> will be untranslatable. Was this done by purpose?
>
> It was done because otherwise fixture strings were translated twice -
> first in the definition and then in the loop.
>
> Patrys ran away but he mentioned that i'm doing it wrong - instead of
> converting to unicode, i should be working with ugettext instead  of
> gettext. So i'm looking into it right now.
> I'm afraid that i've left impression that i'm fixing this hastily, but
> actually it's just my underestimation of the gettext mess.
>
> Toms
>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]