diff options
author | Alexey Shchepin <alexey@process-one.net> | 2004-07-09 22:34:26 +0000 |
---|---|---|
committer | Alexey Shchepin <alexey@process-one.net> | 2004-07-09 22:34:26 +0000 |
commit | d2eab0d5350cd2fc09987d43f39b7f00dde406d6 (patch) | |
tree | 385b91b97e0729b391d7a93eaaa813ac9fc78105 /src/translate.erl | |
parent | * src/Makefile.win32: Updated (thanks to Sergei Golovan) (diff) |
* doc/guide.tex: Updated
* src/msgs/fr.msg: Updated (thanks to Sergei Golovan)
* src/mod_irc/mod_irc.erl: Added handler for disco items requests
(thanks to Sergei Golovan)
* src/mod_vcard.erl: Added option for JUD disabling (thanks to
Sergei Golovan)
* src/mod_configure2.erl: Fixed module stopping (thanks to Sergei
Golovan)
* src/mod_last.erl: Likewise
* src/mod_privacy.erl: Likewise
* src/mod_register.erl: Likewise
* src/mod_roster.erl: Likewise
* src/mod_vcard.erl: Likewise
* src/jd2ejd.erl: Added emergency catches (thanks to Sergei
Golovan)
* src/mod_last.erl: Likewise
* src/ejabberd_sm.erl: Removed needless call to
mod_disco:unregister_feature (thanks to Sergei Golovan)
* src/ejabberd_local.erl: Better support for mod_disco (thanks to
Sergei Golovan)
* src/mod_disco.erl: Likewise
* src/translate.erl: Suport for "default language" option (thanks
to Sergei Golovan)
* src/ejabberd_config.erl: Likewise
* src/ejabberd_c2s.erl: Likewise
* src/ejabberd.hrl: Added 'MYLANG' macros
* src/ejabberd.cfg.example: Updated (thanks to Sergei Golovan)
* doc/guide.tex: Updated (thanks to Sergei Golovan)
* src/win32/ejabberd.cfg: Updated (thanks to Sergei Golovan)
SVN Revision: 241
Diffstat (limited to 'src/translate.erl')
-rw-r--r-- | src/translate.erl | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/src/translate.erl b/src/translate.erl index ebdd96472..664cbed49 100644 --- a/src/translate.erl +++ b/src/translate.erl @@ -60,8 +60,14 @@ load_file(Lang, File) -> case file:consult(File) of {ok, Terms} -> lists:foreach(fun({Orig, Trans}) -> - ets:insert(translations, - {{Lang, Orig}, Trans}) + Trans1 = case Trans of + "" -> + Orig; + _ -> + Trans + end, + ets:insert(translations, + {{Lang, Orig}, Trans1}) end, Terms); {error, Reason} -> exit(file:format_error(Reason)) @@ -72,6 +78,47 @@ translate(Lang, Msg) -> [{_, Trans}] -> Trans; _ -> - Msg + ShortLang = string:substr(Lang, 1, 2), + case ShortLang of + "en" -> + Msg; + Lang -> + translate(Msg); + _ -> + case ets:lookup(translations, {ShortLang, Msg}) of + [{_, Trans}] -> + Trans; + _ -> + translate(Msg) + end + end + end. + +translate(Msg) -> + case ?MYLANG of + undefined -> + Msg; + "en" -> + Msg; + Lang -> + case ets:lookup(translations, {Lang, Msg}) of + [{_, Trans}] -> + Trans; + _ -> + ShortLang = string:substr(Lang, 1, 2), + case ShortLang of + "en" -> + Msg; + Lang -> + Msg; + _ -> + case ets:lookup(translations, {ShortLang, Msg}) of + [{_, Trans}] -> + Trans; + _ -> + Msg + end + end + end end. |