summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-06-22 13:41:27 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-06-22 13:41:27 (GMT)
commita9f64ab24b5965c3bf6f65e0de8b8706fc38ec7c (patch)
tree16958b1e48f20676be13a43575d7923278bcc995 /library
parent687013812cd6ca56d2bfc1c0b75d98a6f8a2d264 (diff)
downloadtcl-a9f64ab24b5965c3bf6f65e0de8b8706fc38ec7c.zip
tcl-a9f64ab24b5965c3bf6f65e0de8b8706fc38ec7c.tar.gz
tcl-a9f64ab24b5965c3bf6f65e0de8b8706fc38ec7c.tar.bz2
Locale guessing of msgcat fails on (some) Windows 7
Diffstat (limited to 'library')
-rw-r--r--library/msgcat/msgcat.tcl34
-rw-r--r--library/msgcat/pkgIndex.tcl2
2 files changed, 33 insertions, 3 deletions
diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl
index 369ed52..0b12dea 100644
--- a/library/msgcat/msgcat.tcl
+++ b/library/msgcat/msgcat.tcl
@@ -13,7 +13,7 @@
package require Tcl 8.5
# When the version number changes, be sure to update the pkgIndex.tcl file,
# and the installation directory in the Makefiles.
-package provide msgcat 1.4.4
+package provide msgcat 1.4.5
namespace eval msgcat {
namespace export mc mcload mclocale mcmax mcmset mcpreferences mcset \
@@ -464,10 +464,40 @@ proc msgcat::Init {} {
#
if {[catch {
package require registry
+ }]} {
+ mclocale C
+ return
+ }
+
+ # First check registry value LocalName present from Windows Vista
+ # which contains the local string as RFC5646, composed of:
+ # [a-z]{2,3} : language
+ # -[a-z]{4} : script (optional, not used)
+ # -[a-z]{2}|[0-9]{3} : territory (optional, numerical region codes not used)
+ # (-.*)* : variant, extension, private use (optional, not used)
+ # Those are translated to local strings.
+ # Examples: de-CH -> de_ch, sr-Latn-CS -> sr_cs, es-419 -> es
+ #
+ if {([registry values $key "LocaleName"] ne "")
+ && [regexp {^([a-z]{2,3})(?:-[a-z]{4})?(?:-([a-z]{2}))?(?:-.+)?$}\
+ [string tolower [registry get $key "LocaleName"]] match locale\
+ territory]} {
+ if {"" ne $territory} {
+ append locale _ $territory
+ }
+ if {![catch {
+ mclocale [ConvertLocale $locale]
+ }]} {
+ return
+ }
+ }
+
+ # then check key locale which contains a numerical language ID
+ if {[catch {
set key {HKEY_CURRENT_USER\Control Panel\International}
set locale [registry get $key "locale"]
}]} {
- mclocale C
+ mclocale C
return
}
#
diff --git a/library/msgcat/pkgIndex.tcl b/library/msgcat/pkgIndex.tcl
index 17ad5db..60c2d3c 100644
--- a/library/msgcat/pkgIndex.tcl
+++ b/library/msgcat/pkgIndex.tcl
@@ -1,2 +1,2 @@
if {![package vsatisfies [package provide Tcl] 8.5]} {return}
-package ifneeded msgcat 1.4.4 [list source [file join $dir msgcat.tcl]]
+package ifneeded msgcat 1.4.5 [list source [file join $dir msgcat.tcl]]