べーすハンドラーに
class BaseHandler(tornado.web.RequestHandler):
def get_user_locale(self):
return tornado.locale.get(*[self.get_cookie('lang', None)])
get_user_locale を上記のように指定すると、
cookie lang に locale の指定があれば、locale テーブルを差し替えられる。
== po file 作成サンプルシェル ==
BASE=.
DOMAINNAME='main'
FILELIST=$BASE/templates
POFILEDIR=$BASE/po
XGETTEXT=`which xgettext`
find $FILELIST -type f > .tmp
touch $POFILEDIR/$DOMAINNAME.pot
$XGETTEXT -j -n -o $POFILEDIR/$DOMAINNAME.pot --keyword=_:1,2 --language=Python -f .tmp
rm .tmp
#for x in "af_ZA" "ar_AR" "bg_BG" "bn_IN" "bs_BA" "ca_ES" "cs_CZ" "cy_GB" "da_DK" "de_DE" "el_GR" "en_GB" "en_US" "es_ES" "es_LA" "et_EE" "eu_ES" "fa_IR" "fi_FI" "fr_CA" "fr_FR" "ga_IE" "gl_ES" "he_IL" "hi_IN" "hr_HR" "hu_HU" "id_ID" "is_IS" "it_IT" "ja_JP" "ko_KR" "lt_LT" "lv_LV" "mk_MK" "ml_IN" "ms_MY" "nb_NO" "nl_NL" "nn_NO" "pa_IN" "pl_PL" "pt_BR" "pt_PT" "ro_RO" "ru_RU" "sk_SK" "sl_SI" "sq_AL" "sr_RS" "sv_SE" "sw_KE" "ta_IN" "te_IN" "th_TH" "tl_PH" "tr_TR" "uk_UA" "vi_VN" "zh_CN" "zh_HK" "zh_TW";
for x in "ja_JP";
do
LOCALE=$x
POPATH=$POFILEDIR/$LOCALE.po
test ! -f $POPATH && touch $POPATH
nkf -wLu $POPATH > $POFILEDIR/$LOCALE.old.po
msgmerge -v $POFILEDIR/$LOCALE.old.po $POFILEDIR/$DOMAINNAME.pot -o $POPATH
done
class BaseHandler(tornado.web.RequestHandler):
def get_user_locale(self):
return tornado.locale.get(*[self.get_cookie('lang', None)])
get_user_locale を上記のように指定すると、
cookie lang に locale の指定があれば、locale テーブルを差し替えられる。
== po file 作成サンプルシェル ==
BASE=.
DOMAINNAME='main'
FILELIST=$BASE/templates
POFILEDIR=$BASE/po
XGETTEXT=`which xgettext`
find $FILELIST -type f > .tmp
touch $POFILEDIR/$DOMAINNAME.pot
$XGETTEXT -j -n -o $POFILEDIR/$DOMAINNAME.pot --keyword=_:1,2 --language=Python -f .tmp
rm .tmp
#for x in "af_ZA" "ar_AR" "bg_BG" "bn_IN" "bs_BA" "ca_ES" "cs_CZ" "cy_GB" "da_DK" "de_DE" "el_GR" "en_GB" "en_US" "es_ES" "es_LA" "et_EE" "eu_ES" "fa_IR" "fi_FI" "fr_CA" "fr_FR" "ga_IE" "gl_ES" "he_IL" "hi_IN" "hr_HR" "hu_HU" "id_ID" "is_IS" "it_IT" "ja_JP" "ko_KR" "lt_LT" "lv_LV" "mk_MK" "ml_IN" "ms_MY" "nb_NO" "nl_NL" "nn_NO" "pa_IN" "pl_PL" "pt_BR" "pt_PT" "ro_RO" "ru_RU" "sk_SK" "sl_SI" "sq_AL" "sr_RS" "sv_SE" "sw_KE" "ta_IN" "te_IN" "th_TH" "tl_PH" "tr_TR" "uk_UA" "vi_VN" "zh_CN" "zh_HK" "zh_TW";
for x in "ja_JP";
do
LOCALE=$x
POPATH=$POFILEDIR/$LOCALE.po
test ! -f $POPATH && touch $POPATH
nkf -wLu $POPATH > $POFILEDIR/$LOCALE.old.po
msgmerge -v $POFILEDIR/$LOCALE.old.po $POFILEDIR/$DOMAINNAME.pot -o $POPATH
done

コメントする