Package dtk :: Package ui :: Module locales

Source Code for Module dtk.ui.locales

 1  #! /usr/bin/env python 
 2  # -*- coding: utf-8 -*- 
 3   
 4  # Copyright (C) 2011 ~ 2012 Deepin, Inc. 
 5  #               2011 ~ 2012 Wang Yong 
 6  #  
 7  # Author:     Wang Yong <lazycat.manatee@gmail.com> 
 8  # Maintainer: Wang Yong <lazycat.manatee@gmail.com> 
 9  #  
10  # This program is free software: you can redistribute it and/or modify 
11  # it under the terms of the GNU General Public License as published by 
12  # the Free Software Foundation, either version 3 of the License, or 
13  # any later version. 
14  #  
15  # This program is distributed in the hope that it will be useful, 
16  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
17  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
18  # GNU General Public License for more details. 
19  #  
20  # You should have received a copy of the GNU General Public License 
21  # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
22   
23  # To test other language, use below method: 
24  #       env LANG=zh_CN LANGUAGE=zh_CN foo.py 
25   
26  from utils import get_parent_dir 
27  import gettext 
28  import os 
29   
30  LOCALE_DIR=os.path.join(get_parent_dir(__file__, 2), "locale") 
31  if not os.path.exists(LOCALE_DIR): 
32      LOCALE_DIR="/usr/share/locale" 
33   
34  _ = None     
35  try: 
36      gettext.bindtextdomain("deepin-ui", LOCALE_DIR) 
37      gettext.textdomain("deepin-ui") 
38      _ = gettext.gettext 
39  except Exception, e: 
40      _ = lambda i : i 
41