Commit 7de05ec7745e6f4da063ea2c2c9bf9acfa1b6134
1 parent
cb2ac436
Exists in
master
and in
6 other branches
ENH: End line of i18nset to Unix
Showing
1 changed file
with
57 additions
and
57 deletions
Show diff stats
invesalius/i18n.py
1 | -#!/usr/bin/env python | ||
2 | -# -*- coding: UTF-8 -*- | ||
3 | - | ||
4 | -#-------------------------------------------------------------------------- | ||
5 | -# Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas | ||
6 | -# Copyright: (C) 2001 Centro de Pesquisas Renato Archer | ||
7 | -# Homepage: http://www.softwarepublico.gov.br | ||
8 | -# Contact: invesalius@cti.gov.br | ||
9 | -# License: GNU - GPL 2 (LICENSE.txt/LICENCA.txt) | ||
10 | -#-------------------------------------------------------------------------- | ||
11 | -# Este programa e software livre; voce pode redistribui-lo e/ou | ||
12 | -# modifica-lo sob os termos da Licenca Publica Geral GNU, conforme | ||
13 | -# publicada pela Free Software Foundation; de acordo com a versao 2 | ||
14 | -# da Licenca. | ||
15 | -# | ||
16 | -# Este programa eh distribuido na expectativa de ser util, mas SEM | ||
17 | -# QUALQUER GARANTIA; sem mesmo a garantia implicita de | ||
18 | -# COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM | ||
19 | -# PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais | ||
20 | -# detalhes. | ||
21 | -#-------------------------------------------------------------------------- | ||
22 | - | ||
23 | -import ConfigParser | ||
24 | -import locale | ||
25 | -import gettext | ||
26 | -import os | ||
27 | -import sys | ||
28 | - | ||
29 | -import utils as utl | ||
30 | - | ||
31 | -def GetLocales(): | ||
32 | - """Return a dictionary which defines supported languages""" | ||
33 | - d = utl.TwoWaysDictionary ({'zh_TW': u'中文', | ||
34 | - 'en': u'English', | ||
35 | - 'es': u'Español', | ||
36 | - 'ko': u'조선어', | ||
37 | - 'pt_BR': u'Português (Brasil)', | ||
38 | - 'pt': u'Português (Portugal)', | ||
39 | - 'fr':u'Français', | ||
40 | - 'el_GR':u'Ελληνική', | ||
41 | - 'it_IT':'Italiano', | ||
42 | - 'de_DE': 'Deutsch'}) | ||
43 | - return d | ||
44 | - | ||
45 | -def GetLocaleOS(): | ||
46 | - """Return language of the operating system.""" | ||
47 | - if sys.platform == 'darwin': | ||
48 | - locale.setlocale(locale.LC_ALL, "") | ||
49 | - return locale.getlocale()[0] | 1 | +#!/usr/bin/env python |
2 | +# -*- coding: UTF-8 -*- | ||
3 | + | ||
4 | +#-------------------------------------------------------------------------- | ||
5 | +# Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas | ||
6 | +# Copyright: (C) 2001 Centro de Pesquisas Renato Archer | ||
7 | +# Homepage: http://www.softwarepublico.gov.br | ||
8 | +# Contact: invesalius@cti.gov.br | ||
9 | +# License: GNU - GPL 2 (LICENSE.txt/LICENCA.txt) | ||
10 | +#-------------------------------------------------------------------------- | ||
11 | +# Este programa e software livre; voce pode redistribui-lo e/ou | ||
12 | +# modifica-lo sob os termos da Licenca Publica Geral GNU, conforme | ||
13 | +# publicada pela Free Software Foundation; de acordo com a versao 2 | ||
14 | +# da Licenca. | ||
15 | +# | ||
16 | +# Este programa eh distribuido na expectativa de ser util, mas SEM | ||
17 | +# QUALQUER GARANTIA; sem mesmo a garantia implicita de | ||
18 | +# COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM | ||
19 | +# PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais | ||
20 | +# detalhes. | ||
21 | +#-------------------------------------------------------------------------- | ||
22 | + | ||
23 | +import ConfigParser | ||
24 | +import locale | ||
25 | +import gettext | ||
26 | +import os | ||
27 | +import sys | ||
28 | + | ||
29 | +import utils as utl | ||
30 | + | ||
31 | +def GetLocales(): | ||
32 | + """Return a dictionary which defines supported languages""" | ||
33 | + d = utl.TwoWaysDictionary ({'zh_TW': u'中文', | ||
34 | + 'en': u'English', | ||
35 | + 'es': u'Español', | ||
36 | + 'ko': u'조선어', | ||
37 | + 'pt_BR': u'Português (Brasil)', | ||
38 | + 'pt': u'Português (Portugal)', | ||
39 | + 'fr':u'Français', | ||
40 | + 'el_GR':u'Ελληνική', | ||
41 | + 'it_IT':'Italiano', | ||
42 | + 'de_DE': 'Deutsch'}) | ||
43 | + return d | ||
44 | + | ||
45 | +def GetLocaleOS(): | ||
46 | + """Return language of the operating system.""" | ||
47 | + if sys.platform == 'darwin': | ||
48 | + locale.setlocale(locale.LC_ALL, "") | ||
49 | + return locale.getlocale()[0] | ||
50 | lc = locale.getdefaultlocale()[0] | 50 | lc = locale.getdefaultlocale()[0] |
51 | if lc: | 51 | if lc: |
52 | return lc | 52 | return lc |
53 | return 'en' | 53 | return 'en' |
54 | - | ||
55 | -def InstallLanguage(language): | ||
56 | - language_dir = os.path.abspath(os.path.join('..','locale')) | ||
57 | - lang = gettext.translation('invesalius', language_dir,\ | ||
58 | - languages=[language], codeset='utf8') | ||
59 | - # Using unicode | ||
60 | - lang.install(unicode=1) | ||
61 | - return lang.ugettext | 54 | + |
55 | +def InstallLanguage(language): | ||
56 | + language_dir = os.path.abspath(os.path.join('..','locale')) | ||
57 | + lang = gettext.translation('invesalius', language_dir,\ | ||
58 | + languages=[language], codeset='utf8') | ||
59 | + # Using unicode | ||
60 | + lang.install(unicode=1) | ||
61 | + return lang.ugettext |