25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-20 17:27:00 +01:00

*** empty log message ***

SVN Revision: 30
This commit is contained in:
Alexey Shchepin 2003-01-06 19:57:05 +00:00
parent 0a9a6261f8
commit a4d2a5557e
8 changed files with 123 additions and 20 deletions

View File

@ -22,6 +22,7 @@ init() ->
Port = open_port({spawn, expat_erl}, [binary]),
db_init(),
sha:start(),
translate:start(),
ejabberd_auth:start(),
ejabberd_router:start(),
ejabberd_sm:start(),

View File

@ -18,3 +18,5 @@
-define(MYNAME,"e.localhost").
-define(MSGS_DIR, "msgs").

View File

@ -46,6 +46,7 @@ register_feature(Feature) ->
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",
@ -64,11 +65,11 @@ process_local_iq_items(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
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" ->

View File

@ -3,6 +3,7 @@
%%% Author : Alexey Shchepin <alexey@sevcom.net>
%%% Purpose :
%%% Created : 5 Jan 2003 by Alexey Shchepin <alexey@sevcom.net>
%%% Id : $Id$
%%%----------------------------------------------------------------------
-module(mod_offline).

View File

@ -57,15 +57,15 @@ process_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
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.

View File

@ -166,18 +166,19 @@ set_vcard(LUser, VCARD) ->
-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"),
@ -205,6 +206,7 @@ do_route(From, To, Packet) ->
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),
@ -231,7 +233,7 @@ do_route(From, To, Packet) ->
[{xmlelement, "x",
[{"xmlns", ?NS_XDATA},
{"type", "result"}],
search_result(XData)
search_result(Lang, XData)
}]}]},
ejabberd_router:route(
To, From, jlib:iq_to_xml(ResIQ))
@ -309,10 +311,12 @@ find_xdata_el1([_ | Els]) ->
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"),

32
src/msgs/ru.msg Normal file
View File

@ -0,0 +1,32 @@
% $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:

62
src/translate.erl Normal file
View File

@ -0,0 +1,62 @@
%%%----------------------------------------------------------------------
%%% 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.