/[tcldrop]/tcldrop/modules/core.tcl
ViewVC logotype

Diff of /tcldrop/modules/core.tcl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by fireegl, Wed May 21 08:45:10 2003 UTC revision 1.5 by fireegl, Thu May 22 05:03:37 2003 UTC
# Line 83  proc ::tcldrop::SetDefault {var {value { Line 83  proc ::tcldrop::SetDefault {var {value {
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    
# Line 93  proc strftime {format {time {}}} { Line 94  proc strftime {format {time {}}} {
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  }  }
# Line 390  proc loadmodule {module {version {}}} { Line 432  proc loadmodule {module {version {}}} {
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    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26