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

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to