From: Jérôme <rom...@ya...> - 2010-11-02 16:29:41
|
> Ah, I see. You are attempting to get the translated string, but from > the current language locally set in the report, not the language > gramps is running in. You need to make sure that you get the > untranslated string, then, before you try to translate it. Otherwise, > you will get the string after it has been translated to the language > gramps is running in, and then attempt to lookup that, which will > probably fail as it is no longer English. Change is on trunk rev16113 http://gramps.svn.sourceforge.net/viewvc/gramps?view=revision&revision=16113 It is not too intrusive. Need some testing, it sounds not bad for me. One issue remains, which I cannot reproduce yet: http://www.gramps-project.org/bugs/view.php?id=4342 http://www.gramps-project.org/bugs/view.php?id=4339 Also Note Type on Source is ignored by translator class (gen/plug/report/endnotes.py), so NoteType() uses our locale translation. As Endnotes are often localized by the user (custom field, note), I suppose this can be ignored for this feature ? For testing, we can try an installation (./autogen with prefix=/home/../trunk, make, make install, do not need root) Or to compile some translations, to put them into some {lang prefix}/LC_MESSAGES/gramps.po and to use : $ GRAMPSI18N=../.. python gramps.py with ../.. the path to {lang prefix} directory. It should also works by running source under a localized distribution, which might uses our locale translation for Gramps 3.2.4 (if installed). Same way by setting a locale and pointing to locale directory for Gramps 3.2.4. Jérôme Doug Blank a écrit : > On Tue, Nov 2, 2010 at 9:17 AM, jerome <rom...@ya...> wrote: >> In fact, we need to still use self._ for matching default (our locale), english (code) and language set, this will be something like : self._(event.get_type_as_xml()). > > Ah, I see. You are attempting to get the translated string, but from > the current language locally set in the report, not the language > gramps is running in. You need to make sure that you get the > untranslated string, then, before you try to translate it. Otherwise, > you will get the string after it has been translated to the language > gramps is running in, and then attempt to lookup that, which will > probably fail as it is no longer English. > > -Doug > >> For working I need to pass throught translator class, so it is limited to detailed reports. >> >> I do not know what is the most practical! >> I use to same method as Brian for get_date() with date handler/displayer (date format set by the user). >> I am just more confortable with a change on plugins.lib rather then gen.lib. >> >> There is still a minor translation issue on endnote (return Note type name with user locale) but this one is very cosmetic. >> >> >> >> Jérôme >> >> --- En date de : Mar 2.11.10, Doug Blank <dou...@gm...> a écrit : >> >>> De: Doug Blank <dou...@gm...> >>> Objet: Re: [Gramps-devel] Re : Re : Translator class on plugins/lib/libtranslate >>> À: "jerome" <rom...@ya...> >>> Cc: gra...@li... >>> Date: Mardi 2 novembre 2010, 12h10 >>> Wouldn't it be better to add this as >>> a method of the base GrampsType: >>> >>> class GrampsType: >>> def get_type_as_xml(self): >>> return >>> GrampsType.xml_str(self.get_type()) >>> >>> and then all types would have this everywhere without >>> adding more >>> code, and without additional imports: >>> >>> event.get_type_as_xml() >>> attribute.get_type_as_xml() >>> >>> Just wondering. >>> >>> -Doug >>> >>> On Tue, Nov 2, 2010 at 6:47 AM, jerome <rom...@ya...> >>> wrote: >>>> OK, it works! >>>> >>>> I will commit a new definition on libtranslate : >>>> >>>> def get_type(self, name): >>>> """ >>>> Return a string representing the name >>> appropriate >>>> for the language being translated. >>>> >>>> :param name: The name type. >>>> :returns: The name as text in the proper >>> language. >>>> :rtype: unicode >>>> """ >>>> return GrampsType.xml_str(name) >>>> >>>> then on reports: >>>> >>>> self.__get_type = translator.get_type >>>> self.__get_type(event.get_type()) >>>> self.__get_type(attribute.get_type()) >>>> self.__get_type(name.get_type()) >>>> >>>> >>>> Regards, >>>> Jérôme >>>> >>>> >>>> --- En date de : Mar 2.11.10, jerome <rom...@ya...> >>> a écrit : >>>>> De: jerome <rom...@ya...> >>>>> Objet: [Gramps-devel] Re : Translator class on >>> plugins/lib/libtranslate >>>>> À: gra...@li... >>>>> Date: Mardi 2 novembre 2010, 10h50 >>>>> Hi, >>>>> >>>>> >>>>> It is general: cannot return translation >>> (according >>>>> language set on detailed reports) for gramps type >>> (name, >>>>> event, attribute, etc..), it always return >>> translation for >>>>> my locale. >>>>> >>>>> Should we try to retrieve all gramps types >>>>> (gen/lib/grampstype.py) ? >>>>> >>>>> To use something like >>> GrampsType.get_standard_xml() (or >>>>> hard coded) and def get_type(self, names) into >>>>> plugins/lib/libtranslate ? >>>>> >>>>> Reports (if need) will use self.__type = >>>>> translator.get_type >>>>> >>>>> >>>>> Jérôme >>>>> >>>>> >>>>> --- En date de : Lun 1.11.10, jerome <rom...@ya...> >>>>> a écrit : >>>>> >>>>>> De: jerome <rom...@ya...> >>>>>> Objet: [Gramps-devel] Translator class on >>>>> plugins/lib/libtranslate >>>>>> À: gra...@li... >>>>>> Date: Lundi 1 novembre 2010, 20h53 >>>>>> Hi, >>>>>> >>>>>> >>>>>> I cannot return the translated string >>> (language set >>>>> on >>>>>> detailed report options) for event type and >>> attribute >>>>> type. >>>>>> These data are on 'More about' boxes, they >>> are not >>>>> used on >>>>>> sentences or main data. >>>>>> >>>>>> I suppose because gen/lib/attrtype and >>>>>> gen/lib/eventtype.py >>>>>> do not import Translator class from >>>>>> plugins.lib.libtranslate >>>>>> >>>>>> Is there a convention for import module ? >>>>>> I cannot make that these gen.lib modules to >>> import >>>>>> Translator class ! Any help is welcome. >>>>>> >>>>>> Or, is there an alternative to: >>>>>> >>>>>> translator = Translator(language) >>>>>> self._ = translator.gettext >>>>>> >>>>>> attrName = str(attr.get_type()) >>>>>> event_name = str(event.get_type()) >>>>>> text = self._("%(attr_name)s %(event_name)s") >>> % { >>>>>> 'attr_name' : >>>>>> self._(attrName), >>>>>> >>>>>> 'event_name' : self._(event_name)} >>>>>> >>>>>> >>>>>> Regards, >>>>>> Jérôme >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>> ------------------------------------------------------------------------------ >>>>>> Nokia and AT&T present the 2010 Calling >>> All >>>>>> Innovators-North America contest >>>>>> Create new apps & games for the Nokia N8 >>> for >>>>> consumers >>>>>> in U.S. and Canada >>>>>> $10 million total in prizes - $4M cash, 500 >>> devices, >>>>> nearly >>>>>> $6M in marketing >>>>>> Develop with Nokia Qt SDK, Web Runtime, or >>> Java and >>>>> Publish >>>>>> to Ovi Store >>>>>> http://p.sf.net/sfu/nokia-dev2dev >>>>>> >>> _______________________________________________ >>>>>> Gramps-devel mailing list >>>>>> Gra...@li... >>>>>> https://lists.sourceforge.net/lists/listinfo/gramps-devel >>>>>> >>>>> >>>>> >>>>> >>>>> >>> ------------------------------------------------------------------------------ >>>>> Nokia and AT&T present the 2010 Calling All >>>>> Innovators-North America contest >>>>> Create new apps & games for the Nokia N8 for >>> consumers >>>>> in U.S. and Canada >>>>> $10 million total in prizes - $4M cash, 500 >>> devices, nearly >>>>> $6M in marketing >>>>> Develop with Nokia Qt SDK, Web Runtime, or Java >>> and Publish >>>>> to Ovi Store >>>>> http://p.sf.net/sfu/nokia-dev2dev >>>>> _______________________________________________ >>>>> Gramps-devel mailing list >>>>> Gra...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/gramps-devel >>>>> >>>> >>>> >>>> >>>> >>> ------------------------------------------------------------------------------ >>>> Nokia and AT&T present the 2010 Calling All >>> Innovators-North America contest >>>> Create new apps & games for the Nokia N8 for >>> consumers in U.S. and Canada >>>> $10 million total in prizes - $4M cash, 500 devices, >>> nearly $6M in marketing >>>> Develop with Nokia Qt SDK, Web Runtime, or Java and >>> Publish to Ovi Store >>>> http://p.sf.net/sfu/nokia-dev2dev >>>> _______________________________________________ >>>> Gramps-devel mailing list >>>> Gra...@li... >>>> https://lists.sourceforge.net/lists/listinfo/gramps-devel >>>> >> >> >> > |