Sunday Mar 25, 2007

JSF Message Localization

At a recent Sun Tech Days conference in Kuala Lumpur, Malaysia, a respected developer said, "Localization is to difficult." I responded, "It is easy, once you know how."

Below are instructions to create a simple localized JSF NetBeans project.
Click here, to download my sample localized JSF NetBeans project.
Click here, to download a more comprehensive localized JSF NetBeans project.
jsfLocale2 moves the message language choice from a JSP into a servlet which makes the choice of language more flexible in the application. jsfLocale2 also uses a JSF backing bean to save and print the logged in user name.


Here is how to localize application messages in JSF:

0. Setup a development environment.
Click here for instruction to setup a NetBeans development environment.

1. Create a NetBeans project named jsfLocale1.
In the web.xml file, update the welcome-file value to make the index.jsp be processed through the JSF control servlet:

	<welcome-file>
            faces/index.jsp
        </welcome-file>

2. Create the default language message property file:
Right mouse button click on
Projects tab/jsfLocale1/Source Packages/<default package>.
Select New/"File/Folder"/Other/Properties File, click Next.
Give the File Name: messages. Click Finish.

3. Create the other language message files, one for each languages your web site is to have. In this example,
3.1 Add German: Right mouse button click on
Projects tab/jsfLocale/Source Packages/<default package>/messages.properties.
Select Add Locale, select de_DE - German / Germany
3.2 Add Chinese: Right mouse button click on
Projects tab/jsfLocale/Source Packages/<default package>/messages.properties.
Select Add Locale, select zh_CN - Chinese / China

4. In the JSF configuration file, faces-config.xml, add the language codes:

...<faces-config ... >
    <application>
        <locale-config>
            <default-locale>en</default-locale>
            <supported-locale>de_DE</supported-locale>
            <supported-locale>zh_CN</supported-locale>
        </locale-config>
    </application>
</faces-config>

5. Enter all the application messages into each of the message files.
Click here to download the sample NetBeans project which contains the message files.

Note, Chinese Characters need to be converted into unicode.
Example: from 中文, to \\u4e2d\\u6587
Sample Windows conversion command:
native2ascii.exe -encoding UTF-8 messages_zh_CN.properties.txt messages_zh_CN.properties
\*\*\* Note, due to a bug, remove the unicode character "\\ufeff", from the first line of the file messages_zh_CN.properties.

6. Run the project. Make changes, re-run.
When making JSP changes, re-load the web page to see the changes.
When making configuration changes, example face-config.xml changes, re-run the project.

Reading and Using Thai Characters

The Thai alphabet is phonic based, similar to English in that each letter/character has an associated sound.
Example: in English, the d has a sound, and my name David, starts with that sound.
In Thai, ด has the same sound as d.

Note, if you cannot see the Thai characters in the article,
Click here, to setup a Windows computer to view Thai characters.

Sample Thai Constants and Their Associated English Sound

Thai
Char
English Equivalent SoundThai Word
b as in Barbaraบาร์บาร่า
ch as in Charlieชาร์ลี
ch as in cha which means teaชา
d as in Davidเดวิด
f as in Fredเฟร็ด
g as in Gregเกร็ก
h as in Hollyฮอลลี่
j as in Jimจิม
k as in Kathyแคธี่
k (low tone) as in Chrisคริส
k (mid tone) as in rak which means loveรัก
l as in Leeลี
m as in Markมาร์ค
n as in Nancyแนนซี่
p as in Patแพท
p as in Paramee (Thai name)ปารม
r as in Robinโรบน
r as in Warisa (Thai name)วริษา
r as in Racha (Thai name)รัชชา
s as in Stanสแตน
s as in Stacyสแตสี or แสตซี่
s as in Steve สตีฟ
s as in Samแซม
sh as in Shawnฌอน
t as in Tomโธม
t as in Pat, where t is falling tone.แพท

Click here, to get a list of common English names written in Thai.

Thai Vowels

Where เ is the a sound in David(เดวิด), แ is the a sound in Ann(แอนน์). The character for the vowel a is written twice when the a sound different.
Using the constants d-ด and n-น, and vowel a-แ, the name Dan, is written as แดน.
\* Yes, the vowel is written before the constant (more about this below).

Other vowel sounds are distinguish as marks above or below a constant.
The e - ี sound in Pete is a mark - ี above the p-พ sound, พีท.
A the slightly different e - ิ sound in Mick is a mark - ิ above the m-ม sound, มิค.
Change the m-ม in Mick to n-น, and get Nick, นิค.
Note, the i sound in Jim, is the same as Mick. Therefore in Thai, Jim จิม, has the same vowel symbol - ิ as Nick, นิค.

Difference between English and Thai

\* There are no upper case or lower case characters in Thai.
\* In some words, the vowel comes before the constant. My name David, is written as เดวิด in Thai. The "a" sound in David in the Thai letter เ, and is written before the d sound. เด is pronounce as "da", as in David. Since all Thai words start with constant followed by vowel, there is really no confusion on the part of a Thai reader.
Look back at the list of names, and notice which names have the vowel written before the constant.
\* In a sentence, there are no spaces between the words. A space indicates a new sentence.
Example: Thank you in Thai is pronounced khop khun khup, and written ขอบคุณครับ.
ขอบคุณครับ separated into words: ขอบ คุณ ครับ

ขอบkhopthank
คุณkhunyou
ครับkhupyes

Use Your Thai

List of Thai constants - To learn to write the Thai alphabet, print the page, and write each letter. Repetition, brings recongnition.

Now that you can recognize some of the letters of Thai, have a look at Wut's blog article that is written Thai. I'm sure you can pick out some of the Thai letters.

Links

\* Thai-English Dictionary
\* Wikipedia: Thai language
\* Wikipedia: Thai alphabet
\* thai-words-alphabet
\* thai-words-soup
\* Learning Thai

Friday Nov 17, 2006

Working with Japanese Characters

The objective of this blog is to make you comfortable with looking at, and working with, Japanese characters (日本語).

Japanese writing has 3 character sets:

1. Kanji, are Japanese characters derived from Chinese characters. For example, the word for country is the same in kanji, as it is in simplified Chinese, 国. These characters are not phonic based characters used to build words, most characters are a word with single associated Japanese syllable, each with a meaning of its own. Some characters have mulitple syllables, such as learning (gaku 学), and sometimes, characters are combined to make more complex words, like university (dai gaku 大学).

2. Hiragana, each character symbol represents either a vowel (such as a あ), or a consonant followed by a vowel. As English writers use the alphabit (ab..z) to build words, Hiragana are used to build words for which there are no kanji, including particles such as kara から "from," and suffixes such as ~san さん "Mr., Mrs., Miss, Ms." Hiragana are also used to give the pronunciation of kanji in a reading aid called furigana.

3. Katakana, phonic based characters, are most used often to write Japanese words from words in other languages. For example, my English name is Stacy which can be written in Katakana as ステイシー, pronounced su ti shī(i). The Thai language is also based on phonic characters used to build words basd on sounds. For example, English names are phonically transcribed in Thai; for example, Stacy is written in Thai as สเตซ.

Sample Japanese text from Mixi, a popular Japanese social web site.
既に招待メールをもらっている方は、メールの文中にある登録用のURLをクリックするか、そのURL をアドレス欄に貼り付けて「Enter(Return)キー」を押して登録作業をおこなってください。
\* This is a modern sample which has characters of kanji, hiragana, and katakana. Note, 3 Japanese character sets are not enough, the text also includes a fourth character set (ab..z), to create English words.
\* If you have read my blog on Chinese characters, you may recognize the characters:
中 central
文 characters/writing
\* I used Google translate, to translate the sample Japanese text into English:
Already the person who receives the invitation mail clicking URL for the register which is Bunchu of the mail, or sticking that URL to the address column and “Enter (Return) pushing the key” please do register job.

Reference: List of popular Japanese web sites.

The Kanji Characters

The number of kanji characters is about 50,000. In elementary school, students are taught 1006 characters, the Kyōiku kanji (education kanji) characters. In junior high and high school, the students are taught an additional 939 characters, called Jōyō kanji.

Like Chinese, kanji characters can be assembled from elementary characters, example:
峠 (mountain pass) made from 山 (mountain), 上 (up) and 下 (down)

Food words: fish 魚, rice 米
When in Tokyo, I went into a small traditional Japanese restaurant; the servers only knew Japanese. My wife can read and write Chinese, she is Chinese, and since some of the food characters are the same in Chinese and Japanese, we managed to order food. The food was a surprise in that we knew we were getting fish, but did not know how it would be cook (fried or steamed). All in all, the Japanese people were friendly and helpful, the food was wonderful and tasty.

Same characters that are the same in Japanese and Chinese:
big 大
small 小
east (東)
north (北)
cat 猫 Japan 日本
Osaka 大阪
Tokyo 東京
country 国 Country
United States 米国 Yes, rice country...do not take insult, rice is the food that sustains life in Japan. Rice, to a Japanese person, is like potato to an Irish person. Or as I like to say, rice is asian potatoes.

Reference: http://en.wikipedia.org/wiki/Kanji

Hiragana

Hiragana are rounded characters, often more simple than kanji characters.

There are 48 base Hiragana Characters. To represent other sounds, diacritics or combinations of the base characters are used. Here is some samples:
ぁ あ ぃ い ぅ う ぇ え ぉ お か が き ぎ く
ぐ け げ こ ご さ ざ し じ す ず せ ぜ そ ぞ た
だ ち ぢ っ つ づ て で と ど な に ぬ ね の は
ば ぱ ひ び ぴ ふ ぶ ぷ へ べ ぺ ほ ぼ ぽ ま み
む め も ゃ や ゅ ゆ ょ よ ら り る れ ろ ゎ わ
ゐ ゑ を ん

The hiragana consist of a basic set of characters, the gojūon , which can be modified in various ways. By adding a dakuten marker (゛), an unvoiced consonant such as k or t is turned into a voiced consonant such as g or d: k→g, t→d, s→z, and h→b. Writing stokes to indicate how to make the sounds. This is different from English, and similar to Sanskrit.

Sample hiragana mapped to English sounds:
か ka
ん n
ゆ yu
う u

Characters are grouped in order to make the sounds of single word:
かんゆう : ka-n-yu-u - persuasion

In a sentence, there are no spaces between words:
わかよたれそつねならむ : wa ka yo ta re so tsu ne na ra mu - What in this world is eternal?

Reference: http://en.wikipedia.org/wiki/Hiragana

katakana

46 katakana characters, are angular characters:

ァ ア ィ イ ゥ ウ ェ エ ォ オ カ ガ キ ギ ク
グ ケ ゲ コ ゴ サ ザ シ ジ ス ズ セ ゼ ソ ゾ タ
ダ チ ヂ ッ ツ ヅ テ デ ト ド ナ ニ ヌ ネ ノ ハ
バ パ ヒ ビ ピ フ ブ プ ヘ ベ ペ ホ ボ ポ マ ミ
ム メ モ ャ ヤ ュ ユ ョ ヨ ラ リ ル レ ロ ヮ ワ
ヰ ヱ ヲ ン ヴ ヵ ヶ ヷ ヸ ヹ ヺ

For a complete list and further explanations, see: http://en.wikipedia.org/wiki/Katakana

Translating Katakana characters to English sounds.

Sample katakana words:
Katakana カタカナ
Canada (en) カナダ Kanada
America アメリカ

Stacy ステイシー : ス テイ シー su ti shī(i)
David デイヴィッド : デ イ ヴィ ッド - de i vi ddo ...note, ッ doubles the sound

wear ウェア - wea
Software (en) ソフトウェア Sofutowea
Hardware (en) ハードウェア Hādowea
Internet (en) インターネット Intānetto

The Katakana symbol ヶ,is pronounced "ka" when used to indicate quantity.
六ヶ月 (six months)

Translating Katakana characters to English sounds. Goto: http://en.wikipedia.org/wiki/Katakana Use find in your browser, search for "ス".

ジョ jo
ン n
John is written ジョン jon

Monday Nov 06, 2006

Working with Chinese Characters

The objective of this blog is to make you comfortable with looking at, and working with, Chinese characters (中文). I thought learning Chinese was impossible, however I am happy to report that it is very easy to get start with recognizing Chinese characters. It is possible to look at Chinese writing and make sense of it.

First, each character is word. Chinese characters originally came from pictures. For example, the Chinese character for mouth, is a square 口. To verify this, use the Google translation tool. In the tool's web page, enter the mouth, select English to Chinese (Simplified), and click Translate. The Chinese character is displayed to the right.

You may of heard, Chinese is written from top to bottom (columns), left to write. This is still true of many Chinese text such as fiction books, and some magazines. However, for Internet web pages, the order is the same as English, from left to right (rows), top to bottom. To see this, go to Ming Pao, a Chinese newspaper web site. Notice that the characters are alined in rows, not columns.

Another modern trend, is that Chinese people use 1,2,3,4,5,6,7,8,9; same as English speaking persons. More traditional Chinese web sites, such as the Ming Pao, will also use the Chinese numbers.

Chinese CharactersEnglishComments
0
1
2
3Did you already guess this one?
4
一,二,三,四,五,六,七,八,九,十1,2,3,4,5,6,7,8,9,10
10Numbers over 9 are written from left to right, same as English
二十20
三十30Like you could not have guessed this one.
四十40

Exercises for the reader to start working with Chinese characters:
1. Open up a document in an editor such as StarOffice, OpenOffice, or Microsoft Word.
2. Copy and paste the Chinese characters for 1 to 10 (一,二,三,四,五,六,七,八,九,十), into your document.
3. On a new line, copy and paste the Chinese characters to make the number 73.
This is view of my work:
.

Multiple Chinese characters are often combined to make the equivalent of a single word of English. I will use dates to demonstrate this. The Chinese characters for March are 三月, or 3月. 月 means moon in English, and when combined with a number, means the month of year.

Chinese Characters EnglishComments
一月JanuaryAlso written 1月.
二月februaryAlso written 2月.
star
星期一Monday
星期二Tuesday
星期三Wednesday
星期日SundayThe exception to the rule, is Sunday.
The SunAlso used to signify day of the month.
YearExample, this year is 2006年.

Another exercises:
1. In your Chinese document, add the Chinese characters of: 月, 日, 星, 年 and 期 (moon, sun, star, year, and period of time).

On a new line, copy and paste the Chinese characters to write
2. Thursday.
3. June 22, 2006.
4. December 2, 2007.
5. Friday.
This is view of some my work:
.
Note, when in doubt how to write something, try to use the Google translation tool.

From a fundamental set of 26 strokes and characters, it is possible to make most every Chinese character you would use in conversation.
Below are samples of building Chinese characters from fundamental strokes:

Chinese CharactersComments
口 八 -> 四Chinese characters mouth and 8 are combined to make the Chinese character 4.
日 生 -> 星Chinese characters sun and born are combined to make the Chinese character star.
女 子 -> 好Chinese characters female and male are combined to make the Chinese character good. The Chinese saying is: A woman and man together is good.

There are 2 fundemental character sets: Simplified and Traditional. In China, about 50 years ago, Simplified Chinese became more and more popular, as it was mandated. Simplified, simply means, some of the Chinese characters are simpler in that it takes less strokes to create them. Simplified is used in what is called mainland China, the main part of China. Traditional is used in Hong Kong and Taiwan.
Example, the word for country in Traditional Chinese is 國, in Simplified, 国.

Chinese Characters EnglishComments
Center or central
中国ChinaThe central country
person
中国人Chinese person, also written 中人
Beautiful
美国America, "America the Beautiful"
Signify a questionSimplified Chinese
Signify a questionTraditional Chinese
YouSame in both Simplified and Traditional Chinese
你好吗?How are you?Simplified Chinese
你好嗎?How are you?Traditional Chinese

Exercise:
1. Translate American person into Simplified and Traditional Chinese.
2. What is your best guess of what this, 中國美丽, translates to in English?

Useful words:

Chinese Characters EnglishComments
小 中 大small-medium-largeUsed for classification of dim sum at Chinese restaurants
Go, as in go to
Not/negation
英文English
中文Chinese writen characters
简体中文Simplified Chinese
谢谢Thank youSimplified Chinese
謝謝Thank youSimplified Chinese

Friday Nov 03, 2006

Preparing to Read the languages of Chinese, Japanese, and Thai

Preparing to read multiple languages is as easy 1, 2, 3.

1. Unix systems generally are setup to handle multiple languages.
For WindowsXP, follow these instructions:
\* From the Control Panel, select Regional and Language Options.
\* On the top of the popup, click the Languages tab.
\* To view Chinese and Japanese, click Install files for East Asian languages.
\* To view Thai characters, click on Install files for complex script and right to left languages (including Thai).
\* Insert your WindowsXP disk, and click OK.
\* The language files are installed from the disk, then the computer needs to be restarted.

2. View foreign text. Below are samples to confirm your system can view the languages I am writing about:
Chinese characters: 中文
Japanese characters, homepage: 日本語, ホームページ
Thai language: ภาษาไทย

3. The first preparation step to use other languages, is to recognize the characters of the language.
For example, English readers recognize the following numbers: 1 2 3
Chinese readers recognize the following Chinese numbers: 一 二 三
Yes, some Chinese is as easy to learn as 一 二 三

Usefull links

\* Google Translate: Since I only write English on my computer, I use Google translate to create samples in other languages.
\* Thai - English translation site. This site is an excellent for learning Thai words, phrases and sentences. Note, Google does not do Thai translations.
\* Ming Pao, a Chinese newspaper web site that is popular with people in Hong Kong.
\* baidu.com, the number one Chinese search site
\* Yahoo!カテゴリ (Yahoo! Japan)
\* กูเกิลประเทศไทย Google Thailand
\* List of top sites: Japan, China, Thailand

\* Beta Chinese lesson.

About

Tech event, training, business, in east and south Asia.

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today