Diff
Not logged in

Differences From Artifact [a424b03e18]:

To Artifact [f718d484b7]:


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
    # Records the mapping between source strings and translated strings.  The
    # dict key is of the form "<locale> <namespace> <src>", where locale and
    # namespace should be themselves dict values and the value is
    # the translated string.
    variable Msgs [dict create]

    # Map of language codes used in Windows registry to those of ISO-639
    if { $::tcl_platform(platform) eq "windows" } {
	variable WinRegToISO639 [dict create  {*}{
	    01 ar 0401 ar_SA 0801 ar_IQ 0c01 ar_EG 1001 ar_LY 1401 ar_DZ
		  1801 ar_MA 1c01 ar_TN 2001 ar_OM 2401 ar_YE 2801 ar_SY
		  2c01 ar_JO 3001 ar_LB 3401 ar_KW 3801 ar_AE 3c01 ar_BH
		  4001 ar_QA
	    02 bg 0402 bg_BG
	    03 ca 0403 ca_ES







|







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
    # Records the mapping between source strings and translated strings.  The
    # dict key is of the form "<locale> <namespace> <src>", where locale and
    # namespace should be themselves dict values and the value is
    # the translated string.
    variable Msgs [dict create]

    # Map of language codes used in Windows registry to those of ISO-639
    if {[info sharedlibextension] eq ".dll"} {
	variable WinRegToISO639 [dict create  {*}{
	    01 ar 0401 ar_SA 0801 ar_IQ 0c01 ar_EG 1001 ar_LY 1401 ar_DZ
		  1801 ar_MA 1c01 ar_TN 2001 ar_OM 2401 ar_YE 2801 ar_SY
		  2c01 ar_JO 3001 ar_LB 3401 ar_KW 3801 ar_AE 3c01 ar_BH
		  4001 ar_QA
	    02 bg 0402 bg_BG
	    03 ca 0403 ca_ES
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
	append ret _$modifier
    }
    return $ret
}

# Initialize the default locale
proc msgcat::Init {} {
    global env tcl_platform

    #
    # set default locale, try to get from environment
    #
    foreach varName {LC_ALL LC_MESSAGES LANG} {
	if {[info exists env($varName)] && ("" ne $env($varName))} {
	    if {![catch {







|







422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
	append ret _$modifier
    }
    return $ret
}

# Initialize the default locale
proc msgcat::Init {} {
    global env

    #
    # set default locale, try to get from environment
    #
    foreach varName {LC_ALL LC_MESSAGES LANG} {
	if {[info exists env($varName)] && ("" ne $env($varName))} {
	    if {![catch {
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
	    return
	}
    }
    #
    # The rest of this routine is special processing for Windows;
    # all other platforms, get out now.
    #
    if {$tcl_platform(platform) ne "windows"} {
	mclocale C
	return
    }
    #
    # On Windows, try to set locale depending on registry settings,
    # or fall back on locale of "C".
    #







|







450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
	    return
	}
    }
    #
    # The rest of this routine is special processing for Windows;
    # all other platforms, get out now.
    #
    if {[info sharedlibextension] ne ".dll"} {
	mclocale C
	return
    }
    #
    # On Windows, try to set locale depending on registry settings,
    # or fall back on locale of "C".
    #
474
475
476
477
478
479
480

481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
    # [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
	return
    }
    #
    # Keep trying to match against smaller and smaller suffixes







>
















<







474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497

498
499
500
501
502
503
504
    # [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
    #
    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\
	    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 locale [registry get $key "locale"]
    }]} {
	mclocale C
	return
    }
    #
    # Keep trying to match against smaller and smaller suffixes