Thread (1 message) 1 message, 1 author, 2016-06-15
DORMANTno replies

[PATCH] git-gui: detect the use of MUI langauge packs on Windows

From: Pat Thoyts <hidden>
Date: 2016-06-15 22:49:57
Subsystem: the rest · Maintainer: Linus Torvalds

The Tcl msgcat package doesn't detect the use of a multi-lingual language
pack on Windows 7. This means that a user may have their display language
set to Japanese but the system installed langauge was English.
This patch reads the relevent registry key to fix this before loading in
the locale specific parts of git-gui.

Signed-off-by: Pat Thoyts <redacted>
---

Pat Thoyts [off-list ref] writes:
Michael Menegakis [off-list ref] writes:
quoted
For some unknown sorcery Microsoft does not refer to 'Locale' the same
as UNIX. There is only a display-characters method, only if a
character set is not unicode. For actual display of language they have
now on 7 a package downloading mechanism to have the whole system show
a language.

On 7 right now I have locale on Greek so that any non-unicode programs
will work with that. But the display language is English and no Greek
or other non-English package has been installed. The location is also
Greece but that doesn't affect other programs either.

In general these settings make almost all programs to display English
by default. Only a minority like git-gui don't.
This is a fault in Tcl on Windows when you are making use of language
packs to switch the display language on Vista or Windows 7. Tcl will
correctly identify your system language but the newer language pack
features make use of additional settings. See
https://sourceforge.net/tracker/?func=detail&aid=3036566&group_id=10894&atid=110894
for more on the Tcl issue.
Until this is fixed upstream you can fix this for all Tcl/Tk programs
(and many others) by ensuring that the LANG environment variable
matches your display locale. ie: if you install the japanese language
pack on an English version of Windows 7 and then set the display
locale to japansese and set the LANG environment variable to LANG=ja
then git gui would appear in Japanese. For Greek - use LANG=gr
It occurred to me that we do not actually have to wait for the patch
mentioned above to be applied to the tcl core. We can patch up the
msgcat package during git-gui startup and check the relevant registry
location to check for a MUI language pack.

This seems to work OK when I check on a Japanese pack on English Win7.

 git-gui.sh |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/git-gui.sh b/git-gui.sh
index d3acf0d..8cba1aa 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -93,6 +93,27 @@ if {![catch {set _verbose $env(GITGUI_VERBOSE)}]} {
 
 package require msgcat
 
+# Check for Windows 7 MUI language pack (missed by msgcat < 1.4.4)
+if {[tk windowingsystem] eq "win32"
+	&& [package vcompare [package provide msgcat] 1.4.4] < 0
+} then {
+	proc _mc_update_locale {} {
+		puts stderr "check for MUI pack"
+		set key {HKEY_CURRENT_USER\Control Panel\Desktop}
+		if {![catch {
+			package require registry
+			set uilocale [registry get $key "PreferredUILanguages"]
+			msgcat::ConvertLocale [string map {- _} [lindex $uilocale 0]]
+		} uilocale]} {
+			if {[string length $uilocale] > 0} {
+				puts stderr "update locale to $uilocale"
+				msgcat::mclocale $uilocale
+			}
+		}
+	}
+	_mc_update_locale
+}
+
 proc _mc_trim {fmt} {
 	set cmk [string first @@ $fmt]
 	if {$cmk > 0} {
-- 
1.7.3.1.msysgit.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help