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)],
X = #xdata{type = form, fields = Fs},
Captcha = #xcaptcha{xdata = X},
BodyString1 = translate:translate(Lang,
<<"Your messages to ~s are being blocked. "
"To unblock them, visit ~s">>),
BodyString = (str:format(BodyString1,
[JID, get_url(Id)])),
BodyString = {<<"Your messages to ~s are being blocked. "
"To unblock them, visit ~s">>, [JID, get_url(Id)]},
Body = xmpp:mk_text(BodyString, Lang),
OOB = #oob_x{url = get_url(Id)},
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},
JID, File, Size, _ContentType, Lang) when MaxSize /= infinity,
Size > MaxSize ->
Text = <<"File larger than ", (integer_to_binary(MaxSize))/binary,
" Bytes.">>,
Text = {<<"File larger than ~w bytes">>, [MaxSize]},
?INFO_MSG("Rejecting file ~s from ~s (too large: ~B bytes)",
[File, jid:to_string(JID), Size]),
{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>>,
To#jid.server),
Reason = translate:translate(Lang, <<"Join the IRC channel here.">>),
Body = str:format(
translate:translate(
Lang, <<"Join the IRC channel in this Jabber ID: ~s">>),
[jid:to_string(RoomJID)]),
BodyTxt = {<<"Join the IRC channel in this Jabber ID: ~s">>,
[jid:to_string(RoomJID)]},
Invite = #message{
body = xmpp:mk_text(Body, Lang),
body = xmpp:mk_text(BodyTxt, Lang),
sub_els = [#muc_user{
invites = [#muc_invite{from = From,
reason = Reason}]},

View File

@ -2723,11 +2723,8 @@ find_changed_items(UJID, UAffiliation, URole,
Nick /= <<"">> ->
case find_jids_by_nick(Nick, StateData) of
[] ->
ErrText = str:format(
translate:translate(
Lang,
<<"Nickname ~s does not exist in the room">>),
[Nick]),
ErrText = {<<"Nickname ~s does not exist in the room">>,
[Nick]},
throw({error, xmpp:err_not_acceptable(ErrText, Lang)});
JIDList ->
JIDList
@ -3299,7 +3296,7 @@ set_config(Opts, Config, ServerHost, Lang) ->
{0, undefined} ->
?ERROR_MSG("set_room_option hook failed for "
"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)};
{Pos, 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, <<"">>}
end,
Instr = translate:translate(
Lang, <<"Choose a username and password to register "
"with this server">>),
if IsCaptchaEnabled and not IsRegistered ->
TopInstr = translate:translate(
Lang, <<"You need a client that supports x:data "
"and CAPTCHA to register">>),
Instr = translate:translate(
Lang, <<"Choose a username and password to register "
"with this server">>),
UField = #xdata_field{type = 'text-single',
label = translate:translate(Lang, <<"User">>),
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))
end;
true ->
Instr = <<"Choose a username and password to register with this server">>,
xmpp:make_iq_result(
IQ,
#register{instructions = translate:translate(Lang, Instr),
#register{instructions = Instr,
username = Username,
password = <<"">>,
registered = IsRegistered})

View File

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

View File

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