A Tcl universal greeting - from a session on tkchat - NEM
namespace eval universal { package require msgcat msgcat::mcset en "Good Morning!" msgcat::mcset de "Good Morning!" "Guten Morgen!" msgcat::mcset es_ES "Good Morning!" "\u00a1Buenas Man~anas!" msgcat::mcset fr_FR "Good Morning!" "Bonjour!" msgcat::mcset du_NL "Good Morning!" "Goedemorgen!" msgcat::mcset sv "Good Morning!" "God morgon!" msgcat::mcset en "Good Afternoon!" msgcat::mcset de "Good Afternoon!" "Guten Tag!" msgcat::mcset es_ES "Good Afternoon!" "\u00a1Buenas Tardes!" msgcat::mcset fr_FR "Good Afternoon!" "Bonne Apres-midi!" msgcat::mcset du_NL "Good Afternoon!" "Goedemiddag!" msgcat::mcset sv "Good Afternoon!" "God kv\u00e4ll!" proc greeting {} { set timeofday [expr {[clock format [clock seconds] -format %p]\ == "AM" ? "Morning" : "Afternoon"}] return [msgcat::mc "Good $timeofday!"] } }
Add other languages. Also, I'm not sure if es_ES is the right code for Spanish. Rule of spanish greetings:
US
AvL (at least) in German business-life:
RS Similar in German: "Guten Morgen" until ~11:00; "Guten Tag" until ~17:00; "Guten Abend" after that. So one should maybe better switch on ranges of %H, instead of the binary %p... See Time-dependent greetings for refined versions.
Michael Schlenker In some parts of northern germany, especially where i live, it's very easy. The universal greeting that can be used at all times is "Moin".
This seems terribly broken to me. For example, shouldn't the line
msgcat::mcset de "Guten Morgen!"
be
msgcat::mcset de "Good Morning!" "Guten Morgen!"
? -- CLN - RS Right, was too much in a hurry, and more concerned with the ranges problem I wrote below. Thanks for the hint; fixed.
AvL Why aren't the english originals stored in a local variable and reused ? I mean sthg like:
set str "Good Morning!" msgcat::mcset en $str msgcat::mcset de $str "Guten Morgen!" msgcat::mcset ... $str "..."
Watch out for non-ASCII characters; the Wiki mangles them. :/ - DKF