From 2ba17918f72d6f2f0042928facbc0563a52c3b54 Mon Sep 17 00:00:00 2001 From: oehhar Date: Thu, 14 Feb 2013 11:09:31 +0000 Subject: Finer granulated catch --- library/msgcat/msgcat.tcl | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl index fbb9730..97ad4fa 100644 --- a/library/msgcat/msgcat.tcl +++ b/library/msgcat/msgcat.tcl @@ -550,24 +550,20 @@ proc msgcat::Init {} { # Those are translated to local strings. # Examples: de-CH -> de_ch, sr-Latn-CS -> sr_cs@latin, es-419 -> es # - if {[catch { - set key {HKEY_CURRENT_USER\Control Panel\International} - 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\ - script territory]} { - if {"" ne $territory} { - append locale _ $territory - } - set modifierDict [dict create latn latin cyrl cyrillic] - if {[dict exists $modifierDict $script]} { - append locale @ [dict get $modifierDict $script] - } - mclocale [ConvertLocale $locale] + set key {HKEY_CURRENT_USER\Control Panel\International} + if { ![catch {registry get $key "LocaleName"} localeName] + && [regexp {^([a-z]{2,3})(?:-([a-z]{4}))?(?:-([a-z]{2}))?(?:-.+)?$}\ + [string tolower $localeName] match locale script territory]} { + if {"" ne $territory} { + append locale _ $territory + } + set modifierDict [dict create latn latin cyrl cyrillic] + if {[dict exists $modifierDict $script]} { + append locale @ [dict get $modifierDict $script] + } + if {![catch { mclocale [ConvertLocale $locale] }]} { + return } - }]} { - mclocale C - return } # then check key locale which contains a numerical language ID -- cgit v0.12