Hi Shawn, Danek, Takeshi :

I have tried the suggestion by both Shawn and Takeshi. Both works fine. I have
made the changes as suggested by Takeshi. Here is latest updated webrev :
https://cr.opensolaris.org/action/browse/pkg/ae112802/7166082-rev3/webrev/

Below two files have updated in this webrev. Rest of the files are not changed.

   src/modules/client/history.py
   src/modules/client/__init__.py

Ran the "pkg history" command with C locale, unicode locale and eucJP locale. Verified
the output. Ran the complete test suite and all test cases passed.

Thanks,
Abhi.

On 06/29/12 07:26, Takeshi Asano wrote:
Hi Shawn, Danek, and Abhi.,

I overlooked the use of gettext.install() in module code
when reviewed rev-1 webrev, sorry.

Shawn is right; gettext.install() should not be used in module
code because it installs to global "_". Application may use
different message domain and/or different method.

It seems to me that just using common approach in modules
i.e. use ofgettext.translation() works. Am I missing point?

_ = gettext.translation("pkg", "/usr/share/locale", fallback=True,
    codeset=locale.getpreferredencoding()).gettext

(this is often done in __init__.py and imported)

BTW, I think the misc.setlocale() call in the client/history.py
can be removed.

Thanks,
Takeshi


On 2012年06月29日 04:50, Danek Duvall wrote:
Shawn Walker wrote:

On 06/28/12 11:19, Danek Duvall wrote:
Shawn Walker wrote:

src/modules/client/history.py:
  lines 107-109: I don't think we should have this here.  Only the
main program module should be setting locale information.

When pkg command is run pkg.client.api is imported as api. The api in
turn imports pkg.client.history as history. During import the _()
function should be available. If not available then gets the error :

    NameError: name '_' is not defined

So I think the lines 107 to 109 which install _() function cannot be
removed from history.py file.

Then we need to consider installing the gettext handler early before our
imports are done.

That might be trickier than the alternative, which is to redo the way
result_l10n is set in history.py. We should probably call _() in the one place it's actually used, and use N_(), possibly in the class definition, or maybe in _HistoryOperation.__new__(), so that it gets put into pkg.pot.

Maybe just stuff the dict into result_text() and cache it on the first
execution.  Simple and should still get results into pkg.pot?

That'd work too.

Danek
_______________________________________________
pkg-discuss mailing list
pkg-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

_______________________________________________
pkg-discuss mailing list
pkg-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss
_______________________________________________
pkg-discuss mailing list
pkg-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to