Understanding Thai locale and Buddhist calendar
I am a Thai leaving in Thailand. However, I usually work on English locale. Only few times I worked with Thai locale and rarely involving in buddhist calendar. The time has come. I have to understand what Thai locale is and how to use it efficiently. I found a good document written by IBM and another one by Sun.
Precisely, locale is not just language but also country and its variant. So the full form of locale setting is as follow.
__
Or in short:
[_[_]]
There are several possible locale for Thai.
-
th_US
orth
- Gregorian calendar with Western digits -
th_TH
- Buddhist calendar with Westen digits -
th_TH_TH
- Buddhist calendar with Thai digits
Above locales are only some languages. For Java it works on JDK 1.4.1 or higher. Unfortunately, Python don't support Thai locale.
>>> import locale >>> locale.setlocale(locale.LC_ALL,'th') Traceback (most recent call last): File "" , line 1, in ? File "/usr/lib/python2.4/locale.py", line 381, in setlocale return _setlocale(category, locale) locale.Error: unsupported locale setting >>> locale.setlocale(locale.LC_ALL,'th_TH') Traceback (most recent call last): File "" , line 1, in ? File "/usr/lib/python2.4/locale.py", line 381, in setlocale return _setlocale(category, locale) locale.Error: unsupported locale setting
Oh, no! That is why Python has not been used in Enterprise application. In fact, Thai locale support is available in Windows platform.
Updated: Actually, Locale module in Python relies on system locale. In order to let the Python support th_TH.TIS-620
and th_TH.UTF-8
, I have to enable it. For Ubuntu:
sudo locale-gen th_TH.TIS-620
sudo locale-gen th_TH.UTF-8
Wow! It works.
Tags: locale, buddhist calendar, java, python
- sugree's blog
- 1189 reads
Post new comment