Package entropy :: Module i18n

Source Code for Module entropy.i18n

 1  # -*- coding: utf-8 -*- 
 2  ''' 
 3      # DESCRIPTION: 
 4      # Entropy Object Oriented Interface 
 5   
 6      Copyright (C) 2007-2009 Fabio Erculiani 
 7   
 8      This program is free software; you can redistribute it and/or modify 
 9      it under the terms of the GNU General Public License as published by 
10      the Free Software Foundation; either version 2 of the License, or 
11      (at your option) any later version. 
12   
13      This program is distributed in the hope that it will be useful, 
14      but WITHOUT ANY WARRANTY; without even the implied warranty of 
15      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
16      GNU General Public License for more details. 
17   
18      You should have received a copy of the GNU General Public License 
19      along with this program; if not, write to the Free Software 
20      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
21  ''' 
22  # pylint ~ ok 
23   
24  import os 
25  _LOCALE = None 
26  _LOCALE_FULL = os.getenv('LC_ALL') 
27  if _LOCALE_FULL == None: 
28      _LOCALE_FULL = os.getenv('LANG') 
29  if _LOCALE_FULL == None: 
30      _LOCALE_FULL = os.getenv('LANGUAGE') 
31   
32  if _LOCALE_FULL: 
33      _LOCALE = _LOCALE_FULL.split('.')[0] 
34      _LOCALE = _LOCALE.split('_')[0] 
35      _LOCALE = _LOCALE.lower() 
36   
37  try: 
38      import gettext 
39      gettext.bindtextdomain('entropy', '/usr/share/locale') 
40      gettext.textdomain('entropy') 
41      gettext.install('entropy', unicode=True) 
42      _ = _ 
43  except (ImportError,OSError,): 
44 - def _(raw_string):
45 """ 46 Fallback in case gettext is not available. 47 48 @param raw_string raw untranslated string 49 @return raw_string untranslated string 50 """ 51 return raw_string
52