PyGTK localisation on Win32

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jwesonga

    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?
  • Jarek Zgoda

    #2
    Re: PyGTK localisation on Win32

    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.setlocal e(locale.LC_ALL , '')
    if os.name == 'nt':
    # windows hack for locale setting
    lang = os.getenv('LANG ')
    if lang is None:
    defaultLang, defaultEnc = locale.getdefau ltlocale()
    if defaultLang:
    lang = defaultLang
    if lang:
    os.environ['LANG'] = lang
    gtk.glade.bindt extdomain(appna me, translation_dir )
    gtk.glade.textd omain(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


    "We read Knuth so you don't have to" - Tim Peters

    Comment

    • Sukhov Dmitry

      #3
      Re: PyGTK localisation on Win32

      >
      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.setlocal e(locale.LC_ALL , '')
      if os.name == 'nt':
      # windows hack for locale setting
      lang = os.getenv('LANG ')
      if lang is None:
      defaultLang, defaultEnc = locale.getdefau ltlocale()
      if defaultLang:
      lang = defaultLang
      if lang:
      os.environ['LANG'] = lang
      gtk.glade.bindt extdomain(appna me, translation_dir )
      gtk.glade.textd omain(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


      Comment

      Working...