Version 20 of Things Japanese

Updated 2003-09-25 17:27:43

Purpose: collect Tcl code specific to the Japanese culture. Part of a series that started with Things British


Common questions about Tcl/Tk and Japanese language support


See http://sourceforge.jp/projects/tcltkjp/ for a project listed as "Tcl/Tk Japanese translation team".


Nengo calculation: The Japanese calendar starts counting years from 1 with each accession of an emperor, who baptizes his era with a two-Kanji name, nengo (see for example http://japanesesword.homestead.com/files/kanji/nengo.htm ). The following nengo are important for recent times:

 Nengo  Long form     Abbreviation  Dates
 Meiji  \u660e\u6cbb  \u337e        1868-1911
 Taisho \u5927\u6b63  \u337d        1912-1925
 Showa  \u662d\u548c  \u337c        1926-1988
 Heisei \u5e73\u6210  \u337b        1989-

For these four eras (and four more free positions), Unicodes have been allocated that render both Kanji into one character. (One might of course also render the two separately, from the regular CJK set). The windows font "Arial Unicode MS" has these four characters, so the following code was possible:

 proc nengo {{year ""}} {
    # convert an AD year (default: this) to nengo style 
    if {$year==""} {set year [clock format [clock seconds] -format %Y]}
    if {$year<1868} {
        error "cannot convert year $year, prior to 1868"
    } elseif {$year<1912} {
        incr year -1867; set nengo \u337E ;# Meiji
    } elseif {$year < 1926} {
        incr year -1911; set nengo \u337D ;# Taisho
    } elseif {$year < 1989} {
        incr year -1925; set nengo \u337C ;# Showa
    } else {
        incr year -1988; set nengo \u337B ;# Heisei
    }
    return $nengo$year
 } ;# RS

Richard is only partly right here. The year 1912 is Meiji 45 Nen until 30 July (7 Gatsu 30 Nichi) and Taisho 1 Nen thereafter; similarly, the year 1926 is Taisho 17 Nen until 25 December (12 Gatsu 25 Nichi) and Showa 1 Nen thereafter, and 1989 is Showa 64 Nen for January 1-7 (1 Gatsu Tsuitachi--Nanoka) and Heisei 1 Nen afterward. The era changes with the death of an emperor. --Kevin Kenny

RS: Yes, point taken (was too lazy to search for the switching dates, and wanted to keep the interface simple). So the above proc, over the 133 years from 1868 to 2001, gets 0.5+0.98+0.02=1.5 nengos wrong, an error rate of 1.1%. We can reduce that to a third by changing the Taisho test to $year < 1927 - and of course to zero by inputting and testing day and month (but clock times only go back to 1902.. See Reworking the clock command)


Japanese weekday names: this list contains the Unicodes for the short names (one Kanji) of what in English is Sunday, Monday,...,Saturday:

        weekdays,ja {\u65e5 \u6708 \u706b \u6c34 \u6728 \u91d1 \u571f}

(from an i15d date chooser). For the long form, append \u66DC\u65e5 (-yoobi); for an intermediate form, only \u66DC.


Japlish: a functional converter from Romaji (7-bit ASCII letters for hiragana and KATAKANA, the two syllabic writing systems used in Japan) to the corresponding Unicodes, plus a handful of Kanji words - add more if you need them...


Hiragana to Katakana: These are the two, basically isomorphic, Japanese syllabic "alphabets" (Katakana \u30f5 and \u30f6 have no Hiragana counterpart). See Example scripts everybody should have for how to convert Hiragana in a string to Katakana by just saying

 [tr \u3041-\u309e \u30a1-\u30fe $japaneseString] 

Input methods are the ways users get Japanese character set data into applications. While there is some support for input methods in Tk, it doesn't yet work on all OSes. But for a quick pure-Tcl solution that does Romaji to Kanji resolution with menus, and e.g. Romaji to Kana translation in a single, half-page string map command, see taiku goes multilingual.


Japanese dates are written in the format (month) \u6708 (date) \u65e5. The month kanji is read "gatsu". The day kanji is read "nichi" except for some irregular combinations (the 1st of the month is "tsuitachi", the 2nd is "futsuka", etc.)


JBDrill, Jim Breen's simple Japanese Flashcard program at [L1 ]


Play with a Japanese abacus (calculator) at TkSoroban


Category Local | i18n - writing for the world | Arts and crafts of Tcl-Tk programming

Category Language