Show More
@@ -6,7 +6,7 b'' | |||||
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | import encoding |
|
8 | import encoding | |
9 | import gettext, sys, os |
|
9 | import gettext, sys, os, locale | |
10 |
|
10 | |||
11 | # modelled after templater.templatepath: |
|
11 | # modelled after templater.templatepath: | |
12 | if getattr(sys, 'frozen', None) is not None: |
|
12 | if getattr(sys, 'frozen', None) is not None: | |
@@ -20,7 +20,25 b" for dir in ('.', '..'):" | |||||
20 | if os.path.isdir(localedir): |
|
20 | if os.path.isdir(localedir): | |
21 | break |
|
21 | break | |
22 |
|
22 | |||
23 | t = gettext.translation('hg', localedir, fallback=True) |
|
23 | _languages = None | |
|
24 | if (os.name == 'nt' | |||
|
25 | and 'LANGUAGE' not in os.environ | |||
|
26 | and 'LC_ALL' not in os.environ | |||
|
27 | and 'LC_MESSAGES' not in os.environ | |||
|
28 | and 'LANG' not in os.environ): | |||
|
29 | # Try to detect UI language by "User Interface Language Management" API | |||
|
30 | # if no locale variables are set. Note that locale.getdefaultlocale() | |||
|
31 | # uses GetLocaleInfo(), which may be different from UI language. | |||
|
32 | # (See http://msdn.microsoft.com/en-us/library/dd374098(v=VS.85).aspx ) | |||
|
33 | try: | |||
|
34 | import ctypes | |||
|
35 | langid = ctypes.windll.kernel32.GetUserDefaultUILanguage() | |||
|
36 | _languages = [locale.windows_locale[langid]] | |||
|
37 | except (ImportError, AttributeError, KeyError): | |||
|
38 | # ctypes not found or unknown langid | |||
|
39 | pass | |||
|
40 | ||||
|
41 | t = gettext.translation('hg', localedir, _languages, fallback=True) | |||
24 |
|
42 | |||
25 | def gettext(message): |
|
43 | def gettext(message): | |
26 | """Translate message. |
|
44 | """Translate message. |
General Comments 0
You need to be logged in to leave comments.
Login now