Fun with Chinese Characters

I am just starting to learn Tcl. Find it's fun when using Chinese Characters.

puts "The next line is in Chinese. Since we don't
use blank space to separate words, {}s and \"s are not needed!"
puts 中文不用空格来分词，所以句子不需要用引号或者大括号。
set cs 白日依山尽，黄河入海流。欲穷千里目，更上一层楼。
puts [string replace $cs end-5 中文更自由。]

Non-ASCII characters are first-class citizens in Tcl (unlike other languages which "support" Unicode as a kind of optional extra). Tcl is therefore a very good foundation for programming in languages other than English. Variables and commands can be named with non-ASCII characters, for example:

set 子 需要用
puts $子

works just fine. Tcl lets you rename and alias commands, so you can also say

interp alias {} 用 {} puts
用 $子

or

rename puts 用
用 $子

If you wish, you can keep the "English" commands in a different place by renaming them:

rename puts en_puts
interp alias {} 用 {} en_puts
用 $子

You can do this in a systematic way, by moving the English commands into a namespace.

With just an hour's work, it would be possible to translate every Tcl command into a different natural language. Command options are more difficult, but could be translated in a substitute command that then calls the "real" command. The most difficult problem is with error messages: is there an easy way to modify the error messages that Tcl sends? If so, English could be completely replaced with an arbitrary natural language.

wdb It is doubtlessly big fun to nationalise via rename ... but a drawback remains: you cannot do the same to the sub commands, e.g. you cannot rename stringis integer to something like German zeichenfolge entspricht ganzzahl ... possibly a tip to improve the command rename?

Lars H: Rather unlikely, in view of how the parsing of subcommands is often hardcoded in C internally. You can however use namespace ensemble to "rename" the subcommands: