1 """i18n and l10n support for git-cola"""
3 import gettext
as _gettext
7 from cola
import resources
9 _null_translation
= _gettext
.NullTranslations()
10 _translation
= _null_translation
14 return _translation
.ugettext(s
)
17 def ngettext(s
, p
, n
):
18 return _translation
.ungettext(s
, p
, n
)
27 if sys
.platform
== 'win32':
30 os
.environ
['LANG'] = locale
31 os
.environ
['LC_MESSAGES'] = locale
32 _gettext
.textdomain('messages')
33 _translation
= _gettext
.translation('git-cola',
34 localedir
=_get_locale_dir(),
39 _translation
= _null_translation
42 def _get_locale_dir():
43 return resources
.prefix('share', 'locale')
46 def _check_win32_locale():
47 for i
in ('LANGUAGE','LC_ALL','LC_MESSAGES','LANG'):
56 # use only user's default locale
57 lang
= locale
.getdefaultlocale()[0]
59 # using ctypes to determine all locales
60 lcid_user
= ctypes
.windll
.kernel32
.GetUserDefaultLCID()
61 lcid_system
= ctypes
.windll
.kernel32
.GetSystemDefaultLCID()
62 if lcid_user
!= lcid_system
:
63 lcid
= [lcid_user
, lcid_system
]
66 lang
= [locale
.windows_locale
.get(i
) for i
in lcid
]
67 lang
= ':'.join([i
for i
in lang
if i
])
68 # set lang code for gettext
70 os
.environ
['LANGUAGE'] = lang
73 # additional strings for translation
81 # qcat titles for various file types
84 N_('View binary file')
88 N_("No changes selected to commit")
89 N_("No changes selected to revert")