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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <patthoyts@xxxxxxxxxxxxxxxxxxxxx>
---

Pat Thoyts <patthoyts@xxxxxxxxxxxxxxxxxxxxx> writes:
>Michael Menegakis <arxeio@xxxxxxxxx> writes:
>>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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]