Added TODO and DEVELOPMENT.
[faces-project.git] / faces / plocale.py
blob3dcd35c7cae15e18a521628e89c3825152b1d796
1 ############################################################################
2 # Copyright (C) 2005 by Reithinger GmbH
3 # mreithinger@web.de
5 # This file is part of faces.
6 #
7 # faces is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # faces is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the
19 # Free Software Foundation, Inc.,
20 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 ############################################################################
23 import gettext
24 import os.path
25 import locale
28 def _get_translation():
29 try:
30 return gettext.translation("faces")
31 except:
32 try:
33 if sys.frozen:
34 path = os.path.dirname(sys.argv[0])
35 path = os.path.join(path, "resources", "faces", "locale")
36 else:
37 path = os.path.split(__file__)[0]
38 path = os.path.join(path, "locale")
40 return gettext.translation("faces", path)
41 except Exception, e:
42 return None
44 def get_gettext():
45 trans = _get_translation()
46 if trans: return trans.ugettext
47 return lambda msg: msg
50 def get_encoding():
51 trans = _get_translation()
52 if trans: return trans.charset()
53 return locale.getpreferredencoding()