Doing some more digging and seeing examples like the following for gnome
pygtk apps, so perhaps this approach of using:
locale.setlocale(locale.LC_ALL, '')
for module in (gettext, gtk.glade):
module.bindtextdomain("pkg", self.application_dir + \
"/usr/share/locale")
module.textdomain("pkg")
gettext.install("pkg", self.application_dir + "/usr/share/locale")
Is what's needed after all. If we do this then we do not need to have
self._ = gettext.gettext and self.parent._ through out the GUI code, the
addition of _ = gettext.gettext could be dropped from misc.py as well.
Then _() will be in the global python namespace for both CLI and GUI.
JR
http://kefir.sourceforge.net/tepache/SimpleGladeApp.html
def bindtextdomain(app_name, locale_dir=None):
try:
import locale
import gettext
locale.setlocale(locale.LC_ALL, "")
gtk.glade.bindtextdomain(app_name, locale_dir)
gettext.install(app_name, locale_dir, unicode=1)
except (IOError,locale.Error), e:
print "Warning", app_name, e
__builtins__.__dict__["_"] = lambda x : x
||
http://www.pointy-stick.com/lca-2005/
import gettext, locale
...
def main(name, version):
gettextName = 'debuggerDemo'
localeDir = '%s/locale' % _currentDir()
gettext.bindtextdomain(gettextName, localeDir)
gettext.textdomain(gettextName)
gettext.install(gettextName, localeDir, unicode = 1)
http://www.pixelbeat.org/programming/i18n.html
Python:
import gettext, locale
gettext.bindtextdomain("fslint", "/usr/share/locale") #sys default used
if localedir=None
locale.setlocale(locale.LC_ALL,'')
gettext.textdomain("fslint")
#Note if you initially do the following, it is much
#faster as lookup for mo file not done for each translation
#(the C version automatically caches the translations so it's not
needed there).
gettext.install("fslint",localedir=None,unicode=1) #None is sys default
locale
jmr wrote:
> New webrev:
>
> http://cr.opensolaris.org/~jmr/pm_4126_v9_Oct31/
>
> Moved the gettext.install() in client.py back into main_func()
>
> Tried experimenting with dropping the gettext.install from installupdate
> and setting _ = gettext.gettext in beadm.py, this did not help when I
> tried to do an update all and I get an error from libbe about _ not
> being a global name. So put it back.
>
> In the end we might just have to settle on adding gettext.install() for
> any underlying python module support in the GUI which cannot use the
> self._ setup in the PM or UM, as well as the textdomain for the glade
> support. If we did that then we could drop the _ = gettext.gettext in
> misc.py and the gettext.install() in installupdate.py as well.
>
> Let me know what you want us to do.
>
> JR
>
>
> jmr wrote:
>
>> Yep - I also wanted to generate a new one but am not able to as I've
>> exceed my disc quota and cannot move any old webrevs to the .trash
>> folder as per instructions on cr.opensolaris.org. Michal has the same
>> problem so assume this is a problem with the machine.
>>
>> I've attached rev8.
>>
>> JR
>>
>>
>>
>
> _______________________________________________
> pkg-discuss mailing list
> [email protected]
> http://mail.opensolaris.org/mailman/listinfo/pkg-discuss
>
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss