Port = open_port({spawn, expat_erl}, [binary]),
db_init(),
sha:start(),
+ translate:start(),
ejabberd_auth:start(),
ejabberd_router:start(),
ejabberd_sm:start(),
-define(MYNAME,"e.localhost").
+-define(MSGS_DIR, "msgs").
+
ets:insert(disco_features, {Feature}).
process_local_iq_items(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
+ Lang = xml:get_tag_attr_s("xml:lang", SubEl),
case Type of
set ->
{iq, ID, error, XMLNS, [SubEl, {xmlelement, "error",
Domains ++
[{xmlelement, "item",
[{"jid", jlib:jid_to_string(To)},
- {"name", "Online Users"},
+ {"name", translate:translate(Lang, "Online Users")},
{"node", "online users"}], []},
{xmlelement, "item",
[{"jid", jlib:jid_to_string(To)},
- {"name", "All Users"},
+ {"name", translate:translate(Lang, "All Users")},
{"node", "all users"}], []}]
}]};
"online users" ->
%%% Author : Alexey Shchepin <alexey@sevcom.net>
%%% Purpose :
%%% Created : 5 Jan 2003 by Alexey Shchepin <alexey@sevcom.net>
+%%% Id : $Id$
%%%----------------------------------------------------------------------
-module(mod_offline).
end
end;
get ->
- {iq, ID, error, XMLNS, [{xmlelement,
- "query",
- [{"xmlns", "jabber:iq:register"}],
- [{xmlelement, "instructions", [],
- {xmlcdata,
- "Choose a username and password "
- "to register with this server."}},
- {xmlelement, "username", [], []},
- {xmlelement, "password", [], []}]}]}
+ {iq, ID, result, XMLNS, [{xmlelement,
+ "query",
+ [{"xmlns", "jabber:iq:register"}],
+ [{xmlelement, "instructions", [],
+ [{xmlcdata,
+ "Choose a username and password "
+ "to register with this server."}]},
+ {xmlelement, "username", [], []},
+ {xmlelement, "password", [], []}]}]}
end.
-define(TLFIELD(Type, Label, Var),
{xmlelement, "field", [{"type", Type},
- {"label", Label},
+ {"label", translate:translate(Lang, Label)},
{"var", Var}], []}).
-define(FORM,
[{xmlelement, "instructions", [],
- [{xmlcdata, "You need a x:data capable client to search"}]},
+ [{xmlcdata, translate:translate(Lang, "You need a x:data capable client to search")}]},
{xmlelement, "x", [{"xmlns", ?NS_XDATA}, {"type", "form"}],
- [{xmlelement, "title", [], [{xmlcdata, "Users Search"}]},
+ [{xmlelement, "title", [],
+ [{xmlcdata, translate:translate(Lang, "Users Search")}]},
{xmlelement, "instructions", [],
- [{xmlcdata, "Fill in fields to search "
- "for any matching Jabber User"}]},
+ [{xmlcdata, translate:translate(Lang, "Fill in fields to search "
+ "for any matching Jabber User")}]},
?TLFIELD("text-single", "User", "user"),
?TLFIELD("text-single", "Full Name", "fn"),
?TLFIELD("text-single", "Name", "given"),
IQ = jlib:iq_query_info(Packet),
case IQ of
{iq, ID, Type, ?NS_SEARCH, SubEl} ->
+ Lang = xml:get_tag_attr_s("xml:lang", SubEl),
case Type of
set ->
XDataEl = find_xdata_el(SubEl),
[{xmlelement, "x",
[{"xmlns", ?NS_XDATA},
{"type", "result"}],
- search_result(XData)
+ search_result(Lang, XData)
}]}]},
ejabberd_router:route(
To, From, jlib:iq_to_xml(ResIQ))
find_xdata_el1(Els).
-define(LFIELD(Label, Var),
- {xmlelement, "field", [{"label", Label}, {"var", Var}], []}).
+ {xmlelement, "field", [{"label", translate:translate(Lang, Label)},
+ {"var", Var}], []}).
-search_result(Data) ->
- [{xmlelement, "title", [], [{xmlcdata, "Users Search Results"}]},
+search_result(Lang, Data) ->
+ [{xmlelement, "title", [],
+ [{xmlcdata, translate:translate(Lang, "Users Search Results")}]},
{xmlelement, "reported", [],
[?LFIELD("JID", "jid"),
?LFIELD("Full Name", "fn"),
--- /dev/null
+% $Id$
+
+% mod_disco.erl
+{"Online Users", "Подключённые пользователи"}.
+{"All Users", "Все пользователи"}.
+
+
+% mod_vcard.erl
+{"You need a x:data capable client to search",
+ "Чтобы воспользоваться поиском, Вам нужен x:data-совместимый клиент"}.
+{"Users Search", "Поиск пользователей"}.
+{"Fill in fields to search for any matching Jabber User",
+ "Заполните поля для поиска пользователя Jabber"}.
+{"Users Search Results", "Результат поиска пользователей"}.
+
+{"User", "Пользователь"}.
+{"Full Name", "Полное имя"}.
+{"Name", "Имя"}.
+{"Middle Name", "Отчество"}.
+{"Family Name", "Фамилия"}.
+{"Nickname", "Псевдоним"}.
+{"Birthday", "День рождения"}.
+{"Country", "Страна"}.
+{"City", "Город"}.
+{"email", "email"}.
+{"Organization Name", "Название организации"}.
+{"Organization Unit", "Отдел организации"}.
+
+
+% Local Variables:
+% mode: erlang
+% End:
--- /dev/null
+%%%----------------------------------------------------------------------
+%%% File : translate.erl
+%%% Author : Alexey Shchepin <alexey@sevcom.net>
+%%% Purpose :
+%%% Created : 6 Jan 2003 by Alexey Shchepin <alexey@sevcom.net>
+%%% Id : $Id$
+%%%----------------------------------------------------------------------
+
+-module(translate).
+-author('alexey@sevcom.net').
+
+-export([start/0,
+ load_dir/1,
+ load_file/2,
+ translate/2]).
+
+-include("ejabberd.hrl").
+
+start() ->
+ ets:new(translations, [named_table, public]),
+ load_dir(?MSGS_DIR),
+ ok.
+
+load_dir(Dir) ->
+ {ok, Files} = file:list_dir(Dir),
+ MsgFiles = lists:filter(
+ fun(FN) ->
+ string:substr(FN, string:len(FN) - 3) == ".msg"
+ end, Files),
+ lists:foreach(
+ fun(FN) ->
+ load_file(string:substr(FN, 1, string:len(FN) - 4),
+ Dir ++ "/" ++ FN)
+ end, MsgFiles),
+ ok.
+
+load_file(Lang, File) ->
+ {ok, Bin} = file:read_file(File),
+ Content = binary_to_list(Bin),
+ parse(Lang, Content).
+
+
+parse(Lang, String) ->
+ case erl_scan:tokens([], String, 0) of
+ {done, Result, Left} ->
+ {ok, Tokens, _} = Result,
+ {ok, Term} = erl_parse:parse_term(Tokens),
+ {Orig, Trans} = Term,
+ ets:insert(translations, {{Lang, Orig}, Trans}),
+ parse(Lang, Left);
+ _ ->
+ ok
+ end.
+
+translate(Lang, Msg) ->
+ case ets:lookup(translations, {Lang, Msg}) of
+ [{_, Trans}] ->
+ Trans;
+ _ ->
+ Msg
+ end.
+