25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Improve translation of some messages

This commit is contained in:
Evgeniy Khramtsov 2016-11-26 10:05:22 +03:00
parent 3ac73f9607
commit 56b30ab598
7 changed files with 29 additions and 47 deletions

View File

@ -100,11 +100,8 @@ create_captcha(SID, From, To, Lang, Limiter, Args) ->
mk_ocr_field(Lang, CID, Type)], mk_ocr_field(Lang, CID, Type)],
X = #xdata{type = form, fields = Fs}, X = #xdata{type = form, fields = Fs},
Captcha = #xcaptcha{xdata = X}, Captcha = #xcaptcha{xdata = X},
BodyString1 = translate:translate(Lang, BodyString = {<<"Your messages to ~s are being blocked. "
<<"Your messages to ~s are being blocked. " "To unblock them, visit ~s">>, [JID, get_url(Id)]},
"To unblock them, visit ~s">>),
BodyString = (str:format(BodyString1,
[JID, get_url(Id)])),
Body = xmpp:mk_text(BodyString, Lang), Body = xmpp:mk_text(BodyString, Lang),
OOB = #oob_x{url = get_url(Id)}, OOB = #oob_x{url = get_url(Id)},
Tref = erlang:send_after(?CAPTCHA_LIFETIME, ?MODULE, Tref = erlang:send_after(?CAPTCHA_LIFETIME, ?MODULE,

View File

@ -579,8 +579,7 @@ process_iq(_From, #iq{}, _State) ->
create_slot(#state{service_url = undefined, max_size = MaxSize}, create_slot(#state{service_url = undefined, max_size = MaxSize},
JID, File, Size, _ContentType, Lang) when MaxSize /= infinity, JID, File, Size, _ContentType, Lang) when MaxSize /= infinity,
Size > MaxSize -> Size > MaxSize ->
Text = <<"File larger than ", (integer_to_binary(MaxSize))/binary, Text = {<<"File larger than ~w bytes">>, [MaxSize]},
" Bytes.">>,
?INFO_MSG("Rejecting file ~s from ~s (too large: ~B bytes)", ?INFO_MSG("Rejecting file ~s from ~s (too large: ~B bytes)",
[File, jid:to_string(JID), Size]), [File, jid:to_string(JID), Size]),
{error, xmpp:err_not_acceptable(Text, Lang)}; {error, xmpp:err_not_acceptable(Text, Lang)};

View File

@ -655,12 +655,10 @@ adhoc_join(From, To, #adhoc_command{lang = Lang, xdata = X} = Request) ->
RoomJID = jid:make(<<Channel/binary, "%", Server/binary>>, RoomJID = jid:make(<<Channel/binary, "%", Server/binary>>,
To#jid.server), To#jid.server),
Reason = translate:translate(Lang, <<"Join the IRC channel here.">>), Reason = translate:translate(Lang, <<"Join the IRC channel here.">>),
Body = str:format( BodyTxt = {<<"Join the IRC channel in this Jabber ID: ~s">>,
translate:translate( [jid:to_string(RoomJID)]},
Lang, <<"Join the IRC channel in this Jabber ID: ~s">>),
[jid:to_string(RoomJID)]),
Invite = #message{ Invite = #message{
body = xmpp:mk_text(Body, Lang), body = xmpp:mk_text(BodyTxt, Lang),
sub_els = [#muc_user{ sub_els = [#muc_user{
invites = [#muc_invite{from = From, invites = [#muc_invite{from = From,
reason = Reason}]}, reason = Reason}]},

View File

@ -2723,11 +2723,8 @@ find_changed_items(UJID, UAffiliation, URole,
Nick /= <<"">> -> Nick /= <<"">> ->
case find_jids_by_nick(Nick, StateData) of case find_jids_by_nick(Nick, StateData) of
[] -> [] ->
ErrText = str:format( ErrText = {<<"Nickname ~s does not exist in the room">>,
translate:translate( [Nick]},
Lang,
<<"Nickname ~s does not exist in the room">>),
[Nick]),
throw({error, xmpp:err_not_acceptable(ErrText, Lang)}); throw({error, xmpp:err_not_acceptable(ErrText, Lang)});
JIDList -> JIDList ->
JIDList JIDList
@ -3299,7 +3296,7 @@ set_config(Opts, Config, ServerHost, Lang) ->
{0, undefined} -> {0, undefined} ->
?ERROR_MSG("set_room_option hook failed for " ?ERROR_MSG("set_room_option hook failed for "
"option '~s' with value ~p", [O, V]), "option '~s' with value ~p", [O, V]),
Txt = <<"Failed to process option '", O/binary, "'">>, Txt = {<<"Failed to process option '~s'">>, [O]},
{error, xmpp:err_internal_server_error(Txt, Lang)}; {error, xmpp:err_internal_server_error(Txt, Lang)};
{Pos, Val} -> {Pos, Val} ->
setelement(Pos, C, Val) setelement(Pos, C, Val)

View File

@ -202,13 +202,13 @@ process_iq(#iq{type = get, from = From, to = To, id = ID, lang = Lang} = IQ,
_ -> _ ->
{false, <<"">>} {false, <<"">>}
end, end,
Instr = translate:translate(
Lang, <<"Choose a username and password to register "
"with this server">>),
if IsCaptchaEnabled and not IsRegistered -> if IsCaptchaEnabled and not IsRegistered ->
TopInstr = translate:translate( TopInstr = translate:translate(
Lang, <<"You need a client that supports x:data " Lang, <<"You need a client that supports x:data "
"and CAPTCHA to register">>), "and CAPTCHA to register">>),
Instr = translate:translate(
Lang, <<"Choose a username and password to register "
"with this server">>),
UField = #xdata_field{type = 'text-single', UField = #xdata_field{type = 'text-single',
label = translate:translate(Lang, <<"User">>), label = translate:translate(Lang, <<"User">>),
var = <<"username">>, var = <<"username">>,
@ -234,10 +234,9 @@ process_iq(#iq{type = get, from = From, to = To, id = ID, lang = Lang} = IQ,
IQ, xmpp:err_internal_server_error(ErrText, Lang)) IQ, xmpp:err_internal_server_error(ErrText, Lang))
end; end;
true -> true ->
Instr = <<"Choose a username and password to register with this server">>,
xmpp:make_iq_result( xmpp:make_iq_result(
IQ, IQ,
#register{instructions = translate:translate(Lang, Instr), #register{instructions = Instr,
username = Username, username = Username,
password = <<"">>, password = <<"">>,
registered = IsRegistered}) registered = IsRegistered})

View File

@ -206,16 +206,14 @@ val_xfield(digest_frequency = Opt, [Val]) ->
case catch binary_to_integer(Val) of case catch binary_to_integer(Val) of
N when is_integer(N) -> N; N when is_integer(N) -> N;
_ -> _ ->
Txt = <<"Value of '~s' should be integer">>, Txt = {<<"Value of '~s' should be integer">>, [Opt]},
ErrTxt = (str:format(Txt, [Opt])), {error, xmpp:err_not_acceptable(Txt, ?MYLANG)}
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
end; end;
val_xfield(expire = Opt, [Val]) -> val_xfield(expire = Opt, [Val]) ->
try xmpp_util:decode_timestamp(Val) try xmpp_util:decode_timestamp(Val)
catch _:{bad_timestamp, _} -> catch _:{bad_timestamp, _} ->
Txt = <<"Value of '~s' should be datetime string">>, Txt = {<<"Value of '~s' should be datetime string">>, [Opt]},
ErrTxt = (str:format(Txt, [Opt])), {error, xmpp:err_not_acceptable(Txt, ?MYLANG)}
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
end; end;
val_xfield(include_body = Opt, [Val]) -> xopt_to_bool(Opt, Val); val_xfield(include_body = Opt, [Val]) -> xopt_to_bool(Opt, Val);
val_xfield(show_values, Vals) -> Vals; val_xfield(show_values, Vals) -> Vals;
@ -226,9 +224,8 @@ val_xfield(subscription_depth = Opt, [Depth]) ->
case catch binary_to_integer(Depth) of case catch binary_to_integer(Depth) of
N when is_integer(N) -> N; N when is_integer(N) -> N;
_ -> _ ->
Txt = <<"Value of '~s' should be integer">>, Txt = {<<"Value of '~s' should be integer">>, [Opt]},
ErrTxt = (str:format(Txt, [Opt])), {error, xmpp:err_not_acceptable(Txt, ?MYLANG)}
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
end. end.
%% Convert XForm booleans to Erlang booleans. %% Convert XForm booleans to Erlang booleans.
@ -237,9 +234,8 @@ xopt_to_bool(_, <<"1">>) -> true;
xopt_to_bool(_, <<"false">>) -> false; xopt_to_bool(_, <<"false">>) -> false;
xopt_to_bool(_, <<"true">>) -> true; xopt_to_bool(_, <<"true">>) -> true;
xopt_to_bool(Option, _) -> xopt_to_bool(Option, _) ->
Txt = <<"Value of '~s' should be boolean">>, Txt = {<<"Value of '~s' should be boolean">>, [Option]},
ErrTxt = (str:format(Txt, [Option])), {error, xmpp:err_not_acceptable(Txt, ?MYLANG)}.
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}.
%% Return a field for an XForm for Key, with data filled in, if %% Return a field for an XForm for Key, with data filled in, if
%% applicable, from Options. %% applicable, from Options.

View File

@ -171,16 +171,14 @@ val_xfield(digest_frequency = Opt, [Val]) ->
case catch binary_to_integer(Val) of case catch binary_to_integer(Val) of
N when is_integer(N) -> N; N when is_integer(N) -> N;
_ -> _ ->
Txt = <<"Value of '~s' should be integer">>, Txt = {<<"Value of '~s' should be integer">>, [Opt]},
ErrTxt = (str:format(Txt, [Opt])), {error, xmpp:err_not_acceptable(Txt, ?MYLANG)}
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
end; end;
val_xfield(expire = Opt, [Val]) -> val_xfield(expire = Opt, [Val]) ->
try xmpp_util:decode_timestamp(Val) try xmpp_util:decode_timestamp(Val)
catch _:{bad_timestamp, _} -> catch _:{bad_timestamp, _} ->
Txt = <<"Value of '~s' should be datetime string">>, Txt = {<<"Value of '~s' should be datetime string">>, [Opt]},
ErrTxt = (str:format(Txt, [Opt])), {error, xmpp:err_not_acceptable(Txt, ?MYLANG)}
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
end; end;
val_xfield(include_body = Opt, [Val]) -> xopt_to_bool(Opt, Val); val_xfield(include_body = Opt, [Val]) -> xopt_to_bool(Opt, Val);
val_xfield(show_values, Vals) -> Vals; val_xfield(show_values, Vals) -> Vals;
@ -191,9 +189,8 @@ val_xfield(subscription_depth = Opt, [Depth]) ->
case catch binary_to_integer(Depth) of case catch binary_to_integer(Depth) of
N when is_integer(N) -> N; N when is_integer(N) -> N;
_ -> _ ->
Txt = <<"Value of '~s' should be integer">>, Txt = {<<"Value of '~s' should be integer">>, [Opt]},
ErrTxt = (str:format(Txt, [Opt])), {error, xmpp:err_not_acceptable(Txt, ?MYLANG)}
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
end. end.
%% Convert XForm booleans to Erlang booleans. %% Convert XForm booleans to Erlang booleans.
@ -202,9 +199,8 @@ xopt_to_bool(_, <<"1">>) -> true;
xopt_to_bool(_, <<"false">>) -> false; xopt_to_bool(_, <<"false">>) -> false;
xopt_to_bool(_, <<"true">>) -> true; xopt_to_bool(_, <<"true">>) -> true;
xopt_to_bool(Option, _) -> xopt_to_bool(Option, _) ->
Txt = <<"Value of '~s' should be boolean">>, Txt = {<<"Value of '~s' should be boolean">>, [Option]},
ErrTxt = (str:format(Txt, [Option])), {error, xmpp:err_not_acceptable(Txt, ?MYLANG)}.
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}.
%% Return a field for an XForm for Key, with data filled in, if %% Return a field for an XForm for Key, with data filled in, if
%% applicable, from Options. %% applicable, from Options.