4 array set langEncoding {}
7 if {[
catch {encoding names}]} {
17 array set transPieces {}
19 set transPieces(F) { P P K R Q D R T B F N C }
20 set untransPieces(F) { P P R K D Q T R F B C N }
21 set transPieces(S) { P P K R Q D R T B A N C }
22 set untransPieces(S) { P P R K D Q T R A B C N }
23 set transPieces(D) { P B K K Q D R T B L N S }
24 set untransPieces(D) { B P K K D Q T R L B S N }
25 set transPieces(I) { P P K R Q D R T B A N C }
26 set untransPieces(I) { P P R K D Q T R A B C N }
27 set transPieces(N) { P p K K Q D R T B L N P }
28 set untransPieces(N) { p P K K D Q T R L B P N }
29 set transPieces(C) { P P K K Q D R V B S N J }
30 set untransPieces(C) { P P K K D Q V R S B J N }
32 set transPieces(G) { P B K K Q D R T B L N S }
33 set untransPieces(G) { B P K K D Q T R L B S N }
34 set transPieces(H) { P G K K Q V R B B F N H }
35 set untransPieces(H) { G P K K V Q B R F B H N }
36 set transPieces(O) { P B K K Q D R T B L N S }
37 set untransPieces(O) { B P K K D Q T R L B S N }
38 set transPieces(W) { P B K K Q D R T B L N S }
39 set untransPieces(W) { B P K K D Q T R L B S N }
40 set transPieces(K) { P P K R Q D R T B A N C }
41 set untransPieces(K) { P P R K D Q T R A B C N }
42 set transPieces(U) { P S K K Q D R T B L N R }
43 set untransPieces(U) { S P K K D Q T R L B R N }
47 if { $::language == "E" || ! $::translatePieces || $msg == "\[end\]"} {
50 if { [
catch {
set t [
string map $::transPieces($::language) $msg]}] } {
56 proc untrans { msg } {
57 if { $::language == "E" || ! $::translatePieces || $msg == "\[end\]"} {
60 if { [
catch {
set t [
string map $::untransPieces($::language) $msg]}] } {
68 proc addLanguage {letter name underline encodingSystem filename} {
69 lappend ::languages $letter
70 set ::langName($letter) $name
71 set ::langUnderline($letter) $underline
72 set ::langEncoding($letter) $encodingSystem
73 set ::langSourceFile($letter) $filename
79 proc menuText {lang tag label underline {helpMsg ""}} {
80 set ::menuLabel($lang,$tag) $label
81 set ::menuUnder($lang,$tag) $underline
83 set ::helpMessage($lang,$tag) $helpMsg
90 proc helpMsg {lang button message} {
91 set ::helpMessage($lang,$button) $message
95 array set translations {}
100 proc translate {lang tag label} {
101 regsub {\\n} $label "\n" label
102 set ::translations($lang,$tag) $label
103 set ::tr($tag) $label
104 foreach extra {":" "..."} {
105 set newtag "${tag}${extra}"
106 set newlabel "${label}${extra}"
107 set ::translations($lang,$newtag) $newlabel
108 set ::tr($newtag) $newlabel
116 proc translateECO {lang pairList} {
117 foreach {from to} $pairList {
118 sc_eco translate $lang $from $to
125 proc tr {tag {lang ""}} {
127 if {$lang == ""} {
set lang $::language}
128 if {$lang == "X"} {
return $tag}
130 if {[
info exists menuLabel($lang,$tag)]} {
131 return $menuLabel($lang,$tag)
133 if {[
info exists menuLabel(E,$tag)]} {
134 return $menuLabel(E,$tag)
137 if {[
info exists tr($tag)]} {
146 proc setLanguage {} {
147 global menuLabel menuUnder helpTitle helpText
150 if { $::translatePieces } {
171 if {[
info exists ::langSourceFile($lang)]} {
172 source -encoding $::langEncoding($lang) [
file nativename [
file join "$::scidTclDir" "lang/$::langSourceFile($lang)"]]
173 unset ::langSourceFile($lang)
177 tk_messageBox -message "Error loading $lang language: $err"
185 foreach i [
array names ::tr] {
186 if {[
info exists ::translations($lang,$i)]} {
187 set ::tr($i) $::translations($lang,$i)
188 }
elseif {[
info exists ::translations(E,$i)]} {
189 set ::tr($i) $::translations(E,$i)
197 proc setLanguageTemp { lang } {
226 addLanguage B {Brazil Portuguese} 0 iso8859-1 portbr.tcl