Version 5 of Time-dependent greetings

Updated 2002-08-09 14:36:25

Richard Suchenwirth 2002-08-09 - In the Tcl chatroom we often notice what difference in greeting a timezone makes: morning in Germany is afternoon in Australia, etc. This brought me to think a little on the algorithm leading to selection of the appropriate greeting. Even just on the examples of English and German I notice that the boundaries appear not to be the same - "good afternoon" just cannot be translated to "guten Nachmittag", it is too un-idiomatic.

Contributions for other languages are gladly taken (as usual!-)

 proc greet'en {} {
     scan  [clock format [clock sec] -format %H] %d hr
     foreach {maxhr word} {
         12 morning 18 afternoon 22 evening 99 night
     } {if {$hr < $maxhr} break}
     return "good $word"
 }
 proc greet'de {} {
     scan  [clock format [clock sec] -format %H] %d hr
     foreach {maxhr word} {
         11 "n Morgen" 17 "n Tag" 22 "n Abend" 99 " Nacht"
     } {if {$hr < $maxhr} break}
     return Gute$word
 }
 proc greet'es-ar {} {
     scan  [clock format [clock sec] -format %H] %d hr
     foreach {maxhr word} {
         12 "os d��as" 19 "as tardes" 99 "as noches"
     } {if {$hr < $maxhr} break}
     return buen$word
 }
 proc greet'fr{} {
     scan  [clock format [clock sec] -format %H] %d hr
     foreach {maxhr word} {
         19 "jour" 99 "soir"
     } {if {$hr < $maxhr} break}
     return bon$word
 }

 % greet'en
 good afternoon
 % greet'de
 Guten Tag

Natural languages | Arts and crafts of Tcl-Tk programming