Version 9 of Time-dependent greetings

Updated 2002-08-22 10:56:06

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} ;# (1)
     return "good $word"
 }
 proc greet'en-au {} {
            return "G'day" ;# stevel
 }
 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
 }
 proc greet'pt {} {
     scan  [clock format [clock sec] -format %H] %d hr
     foreach {maxhr word} {
         12 "bom dia" 19 "boa tarde" 99 "boa noite"
     } {if {$hr < $maxhr} break}
     return $word
 }  

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

(1): kennykb: "Good night" is non-idiomatic as a greeting. How about "Good heavens, why are you awake at this hour?"


Natural languages | Arts and crafts of Tcl-Tk programming