From: Peter L. <pet...@te...> - 2010-01-05 17:10:20
|
Den Tuesday 05 January 2010 17.47.25 skrev Peter Landgren: > Den Tuesday 05 January 2010 17.16.36 skrev Benny Malengier: > > 2010/1/5 Peter Landgren <pet...@te...>: > > > Den Tuesday 05 January 2010 16.47.31 skrev Benny Malengier: > > >> 2009/12/30 Peter Landgren <pet...@te...>: > > >> > Devs, > > >> > > > >> > I did some testing to try to solve: > > >> > http://www.gramps-project.org/bugs/view.php?id=3480 > > >> > > > >> > I came up with this patch: > > >> > > > >> > Index: _PeopleModel.py > > >> > =================================================================== > > >> > --- _PeopleModel.py (revision 13939) > > >> > +++ _PeopleModel.py (arbetskopia) > > >> > > > >> > @@ -527,7 +527,7 @@ > > >> > GrampsLocale.codeset) > > >> > > > >> > def column_gender(self, data, node): > > >> > - return PeopleModel._GENDER[data[PeopleModel._GENDER_COL]] > > >> > + return > > >> > unicode(PeopleModel._GENDER[data[PeopleModel._GENDER_COL]]) > > >> > > > >> > def column_birth_day(self, data, node): > > >> > try: > > >> > > > >> > My question is: is this the best place for the unicode conversion or > > >> > should it be done somewhere else? > > >> > > >> Peter, only reading this now. How did you solve this? We should avoid > > >> conversions on every line in a listmodel. > > >> > > >> Benny > > > > > > I found that for all views, except Notes View, strings of type 'str' > > > was used to populate columns, which got their values from a drop down > > > list from the beginning, or you could say a "constant". In Notes View > > > there was a 'unicode' conversion function already. So I did the same > > > for Event, Family, People and Repository views, > > > > > > I agree that we should not do any unnecessary conversions. I think this > > > could be a result of gettext always returning a 'str' and not a > > > 'unicode' even if the original English string is defined as _(u"what > > > ever"). I have not been able to proof it yet. > > > > I cannot believe this. Gettext returns chinese. > > PROOF: > This code: > a = u"unknown" > b = _(u"unknown") > > print type(a), a > print type(b), b > > result in: > <type 'unicode'> unknown > <type 'str'> okänd > > /Peter > > > Gerald, looking at eg notemodel, I guess we should add a __unicode__ > > method to grampstype, no? Then we can change all unicode(str(..)) > > constructs into unicode(..), or is there more to it... . We do save > > unicode in the database. > > > > Benny > > > > > /Peter There is ugettext: ugettext(message)¶ If a fallback has been set, forward ugettext() to the fallback. Otherwise, return the translated message as a Unicode string. Overridden in derived classes. But I don't think is used anywher in Gramps. /Peter |