[pygtk] Translation: Different locales directories
Cornelius Kölbel
cornelius.koelbel at lsexperts.de
Mon May 31 19:02:23 WST 2010
Am 31.05.2010 11:33, schrieb Walter Leibbrandt:
> Op 30/05/2010 18:04, het Cornelius Kölbel geskryf:
>
>> Hello List,
>>
>> i got an application with translation.
>>
>> I am doing this...
>>
>> gettext.bindtextdomain(APP_NAME, LOCALE_DIR)
>> gettext.textdomain(APP_NAME)
>>
>> But my problem is, that I do different packaging types like source, deb
>> and rpm. In these different cases, the location of the mo file is not
>> the same for the different packages.
>>
>> What is the recommended way to handle this?
>> Can I provide more than one locale dirs?
>> Should I change the code, for each packaging type?
>> Should I set an environment variable that contains the correct locales dir?
>>
> The get_abs_data_filename() function [1] as used by Virtaal [2] does the
> job on at least Windows and Linux, running from source or from intsallation.
>
> Another solution I've seen is to calculate this location on installation
> and programmatically change a specific source file, from where this
> value is imported/accessed by the application.
>
> [1]:
> https://translate.svn.sourceforge.net/svnroot/translate/src/trunk/translate/misc/file_discovery.py
> [2]:
> https://translate.svn.sourceforge.net/svnroot/translate/src/trunk/virtaal/virtaal/views/baseview.py
>
> HTH,
>
Hello Walter,
hm, I am not that content with importing new modules...
So I did it this way - be it nice or not....
# Determine LOCALE_DIR
system=platform.system()
locale.setlocale(locale.LC_ALL, '')
localedir_testfile = "de/LC_MESSAGES/myapp.mo"
localeDirsLinux=( '',
'locale',
sys.prefix + 'share/locale/',
'/usr/local/share/locale/'
)
LOCALE_DIR = "/usr/local/share/locale"
if system=="Linux":
for dir in localeDirsLinux:
if os.path.isfile(dir+"/"+localedir_testfile):
LOCALE_DIR=dir
break
Thanks for the feedback and kind regards
Cornelius
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20100531/88f46e7d/attachment.pgp
More information about the pygtk
mailing list