Skip to content

Commit 85c6b5f

Browse files
committedOct 24, 2015
Better gettext support for protocol version mismatch messages
Previously, xgettext failed to resolve the dynamic call. Thanks to @JakubVanek for pointing this out.
1 parent 2f19abd commit 85c6b5f

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed
 

‎builtin/mainmenu/common.lua

+22-9
Original file line numberDiff line numberDiff line change
@@ -284,17 +284,30 @@ function text2textlist(xpos,ypos,width,height,tl_name,textlen,text,transparency)
284284
end
285285

286286
--------------------------------------------------------------------------------
287-
function is_server_protocol_compat(proto_min, proto_max)
288-
return not ((min_supp_proto > (proto_max or 24)) or (max_supp_proto < (proto_min or 13)))
287+
function is_server_protocol_compat(server_proto_min, server_proto_max)
288+
return not ((min_supp_proto > (server_proto_max or 24)) or (max_supp_proto < (server_proto_min or 13)))
289289
end
290290
--------------------------------------------------------------------------------
291-
function is_server_protocol_compat_or_error(proto_min, proto_max)
292-
if not is_server_protocol_compat(proto_min, proto_max) then
293-
gamedata.errormessage = fgettext_ne("Protocol version mismatch, server " ..
294-
((proto_min ~= proto_max) and "supports protocols between $1 and $2" or "enforces protocol version $1") ..
295-
", we " ..
296-
((min_supp_proto ~= max_supp_proto) and "support protocols between version $3 and $4." or "only support protocol version $3"),
297-
proto_min or 13, proto_max or 24, min_supp_proto, max_supp_proto)
291+
function is_server_protocol_compat_or_error(server_proto_min, server_proto_max)
292+
if not is_server_protocol_compat(server_proto_min, server_proto_max) then
293+
local server_prot_ver_info
294+
local client_prot_ver_info
295+
if server_proto_min ~= server_proto_max then
296+
server_prot_ver_info = fgettext_ne("Server supports protocol versions between $1 and $2. ",
297+
server_proto_min or 13, server_proto_max or 24)
298+
else
299+
server_prot_ver_info = fgettext_ne("Server enforces protocol version $1. ",
300+
server_proto_min or 13)
301+
end
302+
if min_supp_proto ~= max_supp_proto then
303+
client_prot_ver_info= fgettext_ne("We support protocol versions between version $1 and $2.",
304+
min_supp_proto, max_supp_proto)
305+
else
306+
client_prot_ver_info = fgettext_ne("We only support protocol version $1.", min_supp_proto)
307+
end
308+
gamedata.errormessage = fgettext_ne("Protocol version mismatch. ")
309+
.. server_prot_ver_info
310+
.. client_prot_ver_info
298311
return false
299312
end
300313

4 commit comments

Comments
 (4)

ShadowNinja commented on Oct 27, 2015

@ShadowNinja
Contributor

This causes word order issues. (must be proto_mismatch, server_info, client_info)

est31 commented on Oct 27, 2015

@est31
ContributorAuthor

Its three different sentences, each terminated with a dot. The only thing I assume from a language is that it is split in sentences, and that different sentences can share a context.

ShadowNinja commented on Oct 27, 2015

@ShadowNinja
Contributor

@est31: No, if a language uses an ordering like (client_info, proto_mismatch, server_info) it won't work.

est31 commented on Oct 27, 2015

@est31
ContributorAuthor

Its proto_mismatch. server_info. client_info.. They are three distinct sentences. If it is an issue, then its no word order issue, but a sentence order issue. But I highly doubt there is any language that has rules distinct sentences. You might not catch the metrum, so there won't be a translation for LATIN_ELEGIC_DYSTICHON, but I can live with that. Do you know a language where the current order imposes problems?

Please sign in to comment.