473,385 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

PyGTK localisation on Win32

I've built an app on linux which we have managed to localise into at
least three languages, the app runs well using this command LANG=fr_FR
python app.py which would translate the app into french. We've tried
the replicate the same principle on windows but so far nothing works,
the app will need to be translated into other languages that have no
locale, in windows is there a way to have Glade load values from a
textfile instead of trying to use the .mo files?
Mar 25 '08 #1
2 1378
jwesonga pisze:
I've built an app on linux which we have managed to localise into at
least three languages, the app runs well using this command LANG=fr_FR
python app.py which would translate the app into french. We've tried
the replicate the same principle on windows but so far nothing works,
the app will need to be translated into other languages that have no
locale, in windows is there a way to have Glade load values from a
textfile instead of trying to use the .mo files?
I had no problem with using standard gettext way of doing i18n on
Windows with PyGTK an Glade, apart some quirks with LANG environment
variable. Basically, the code that works looks like this:

import gettext, locale
locale.setlocale(locale.LC_ALL, '')
if os.name == 'nt':
# windows hack for locale setting
lang = os.getenv('LANG')
if lang is None:
defaultLang, defaultEnc = locale.getdefaultlocale()
if defaultLang:
lang = defaultLang
if lang:
os.environ['LANG'] = lang
gtk.glade.bindtextdomain(appname, translation_dir)
gtk.glade.textdomain(appname)
gettext.install(appname, translation_dir, unicode=True)

Be aware, that you can not change the locale setting from the command
line like you do on Linux.

--
Jarek Zgoda
http://zgodowie.org/

"We read Knuth so you don't have to" - Tim Peters
Mar 25 '08 #2
>
I had no problem with using standard gettext way of doing i18n on
Windows with PyGTK an Glade, apart some quirks with LANG environment
variable. Basically, the code that works looks like this:

import gettext, locale
locale.setlocale(locale.LC_ALL, '')
if os.name == 'nt':
# windows hack for locale setting
lang = os.getenv('LANG')
if lang is None:
defaultLang, defaultEnc = locale.getdefaultlocale()
if defaultLang:
lang = defaultLang
if lang:
os.environ['LANG'] = lang
gtk.glade.bindtextdomain(appname, translation_dir)
gtk.glade.textdomain(appname)
gettext.install(appname, translation_dir, unicode=True)

Be aware, that you can not change the locale setting from the command
line like you do on Linux.
I have the same problem. I did all as you wrote. gettext translations
do work fine. But translations in glade does not work.

The only way to turn it on is to set environment variable LANG
explicitly before program run:
set LANG=ru_RU
python test.py
Mar 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: carljohan.rehn | last post by:
I would like like to start doing some GUI-programming in Python, but don't know which library to choose. Tkinter seems a bit old. Correct me if I am wrong! The layout doesn't look as nice as for...
1
by: sebb | last post by:
I just want to know how to install pyGTK on windows. Thanks
6
by: Edwin Young | last post by:
Hi, I'm writing a fractal-generating program in a mixture of C and Python. Python handles all the GUI parts using PyGTK. After finishing the calculations, I have a buffer containing the RGB data...
5
by: Viktor | last post by:
Did anybody managed to "pack", a program that uses pygtk with pyexe? The best result I got was: Pango-ERROR **: file shape.c: line 75 (pango_shape): assertion faled: (glyphs->num_glyphs > 0)...
22
by: dcrespo | last post by:
Hi all... I think wxPython is much better than PyGTK. First of all, PyGTK needs the GTK runtime installed, whereas wxPython is entirely Python's modules, so It facilitates the apps'...
25
by: TPJ | last post by:
GUI's etc: PyGtk on Windows "(...) So if someone develops mainly for X and just wants to make sure that it is not impossible to run on Windows, you can use PyGTK. (...)", July 2nd, 1999 pyGTK...
0
by: kingcrowbar.list | last post by:
Hello Everyone I have been playing a little with pyGTK and threading to come up with simple alert dialog which plays a sound in the background. The need for threading came when in the first...
2
by: fury | last post by:
Hey guys n gals I am using resource file to localise my user interface. But i have an issue with it. When i use assembly key file does not become strong!! and localisation does not work... When i...
0
by: He Jibo | last post by:
Hi, Everyone, Could someone help me how to install pygtk? I get some problems with it. Here is the error I get while install pygtk: https://netfiles.uiuc.edu/jibohe2/error.GIF?uniq=-k6678k ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.