83 |
::tcldrop::SetDefault my-ip {} |
::tcldrop::SetDefault my-ip {} |
84 |
::tcldrop::SetDefault owner {} |
::tcldrop::SetDefault owner {} |
85 |
::tcldrop::SetDefault nick {Tcldrop} |
::tcldrop::SetDefault nick {Tcldrop} |
86 |
|
::tcldrop::SetDefault lang-path {language/} |
87 |
|
|
88 |
proc unixtime {} { clock seconds } |
proc unixtime {} { clock seconds } |
89 |
|
|
94 |
clock format $time -format $format |
clock format $time -format $format |
95 |
} |
} |
96 |
|
|
97 |
|
proc addlang {language {module {core}}} { |
98 |
|
set ::lang $language |
99 |
|
set retval 0 |
100 |
|
# Loading Eggdrop's .lang's first, and then ours, so that ours can override Eggdrops if needed. |
101 |
|
foreach d [list [file join ${::lang-path} eggdrop] ${::lang-path}] { |
102 |
|
foreach f [glob -nocomplain -type f [file join $d "${module}.${language}.lang"]] { |
103 |
|
set fid [open $f r] |
104 |
|
set continued 0 |
105 |
|
while {[gets $fid line] >= 0} { |
106 |
|
if {[string equal [string index $line 0] {#}]} { |
107 |
|
continue |
108 |
|
} elseif {[string equal [string index $line end] "\\"]} { |
109 |
|
set text [subst -nocommands -novariables [string range $line 0 end-1]] |
110 |
|
} else { |
111 |
|
set text [subst -nocommands -novariables $line] |
112 |
|
} |
113 |
|
if {!$continued} { |
114 |
|
set id [string trimright [string range $text 0 [set separator [string first {,} $text]]] {,}] |
115 |
|
set text [string trimleft [string range $text $separator end] {,}] |
116 |
|
set ::tcldrop::lang($id) $text |
117 |
|
} else { |
118 |
|
append ::tcldrop::lang($id) [subst -nocommands -novariables $text] |
119 |
|
} |
120 |
|
set continued [string equal [string index $line end] "\\"] |
121 |
|
} |
122 |
|
close $fid |
123 |
|
set retval 1 |
124 |
|
} |
125 |
|
} |
126 |
|
return $retval |
127 |
|
} |
128 |
|
|
129 |
|
if {[info exists env(EGG_LANG)]} { |
130 |
|
# Load the language specified in the EGG_LANG env variable: |
131 |
|
addlang $env(EGG_LANG) |
132 |
|
} else { |
133 |
|
# English is the default language, but |
134 |
|
# users can still override it by adding an addlang command to their config. |
135 |
|
addlang english |
136 |
|
} |
137 |
|
|
138 |
proc logfile {levels channel filename} { |
proc logfile {levels channel filename} { |
139 |
# FixMe: Complete this. |
# FixMe: Complete this. |
140 |
} |
} |
432 |
puterrlog "$::errorInfo" |
puterrlog "$::errorInfo" |
433 |
} else { |
} else { |
434 |
catch { namespace import -force "tcldrop::${module}::*" } |
catch { namespace import -force "tcldrop::${module}::*" } |
435 |
putlog "Module loaded: $module" |
# Load the corresponding .lang file: |
436 |
|
if {[addlang $::lang $module]} { |
437 |
|
putlog "Module loaded: $module (with $::lang support)" |
438 |
|
} else { |
439 |
|
putlog "Module loaded: $module" |
440 |
|
} |
441 |
} |
} |
442 |
} |
} |
443 |
|
|