Ignore:
Timestamp:
05/05/12 12:16:30 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Enhanced language handling to run the program in the proper environment for gettext

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/config.py

    r149 r155  
    345345        """Get the option name for the given message type level."""
    346346        return const.messageType2string(messageType)
    347        
     347
     348    def setupLocale(self):
     349        """Setup the locale based on the language set.
     350
     351        Return True if a specific language was set, False otherwise."""
     352        import locale
     353        if self._language:
     354            print "Setting up locale for", self._language
     355            os.environ["LANGUAGE"] = self._language
     356            langAndEncoding = self._language + "." + locale.getpreferredencoding()
     357            print langAndEncoding
     358            os.environ["LANG"] = langAndEncoding
     359            os.environ["LC_MESSAGES"] = langAndEncoding
     360            os.environ["LC_COLLATE"] = langAndEncoding
     361            os.environ["LC_CTYPE"] = langAndEncoding
     362            return True
     363        else:
     364            return False
     365
    348366    def getLanguage(self):
    349367        """Get the language to be used."""
Note: See TracChangeset for help on using the changeset viewer.