MythTV  master
i18n.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 # smolt - Fedora hardware profiler
3 #
4 # Copyright (C) 2007 Mike McGrath
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20 import locale
21 try:
22  locale.setlocale(locale.LC_ALL, '')
23 except locale.Error:
24  locale.setlocale(locale.LC_ALL, 'C')
25 #print locale.LC_ALL
26 
27 import os
28 import gettext
29 import sys
30 
31 try:
32  if os.path.isdir('po'):
33  # if there is a local directory called 'po' use it so we can test
34  # without installing
35  #t = gettext.translation('smolt', 'po', fallback = True)
36  t = gettext.translation('smolt', '/usr/share/locale/', fallback = True)
37  else:
38  t = gettext.translation('smolt', '/usr/share/locale/', fallback = True)
39 except IndexError:
40  locale.setlocale(locale.LC_ALL, 'C')
41  t = gettext.translation('smolt', '/usr/share/locale/', fallback=True, languages='en_US')
42 
43 if sys.version_info[0] == 2:
44  _ = t.ugettext
45 else:
46  _ = t.gettext