Content deleted Content added
No edit summary |
sync from sandbox; |
||
Line 1,028:
return name; -- name from data tables or nil
end
--[[--------------------------< T E X T _ S C R I P T _ M A T C H _ T E X T >----------------------------------
IETF script subtag should match the script of the <text>. This module does not attempt to know all scripts and
what they look like. It does know what Latn script look like so when <text> is written using other than the Latn
script, the IETF script, if present, should not be Latn.
Conversely, when <text> is written using the Latn script, the IETF script, if present, should be Latn.
returns an error message when mismatch detected; nil else
]]
local function text_script_match_test (script, is_latn_text)
--error (script)
if is_set (script) then -- don't bother with the rest of this if <script> is nil or empty string
if is_latn_text then -- when text is wholly Latn script
if ('Latn' ~= script and 'latn' ~= script) then -- but a non-Latn script is specified
return 'Latn text/non-Latn script subtag mismatch'; -- emit an error message
end
else -- when text is not wholly Latn script
if ('Latn' == script or 'latn' == script) then -- but Latn script is specified
return 'Non-latn text/Latn script subtag mismatch'; -- emit an error message
end
end
end
end
Line 1,092 ⟶ 1,121:
if msg then
return make_error_msg ( msg, args, template);
end
local is_latn_text = unicode.is_Latin (args.text); -- make a boolean
msg = text_script_match_test (subtags.script, is_latn_text)
if msg then -- if an error detected then there is an error message
return make_error_msg (msg, args, template);
end
Line 1,101 ⟶ 1,137:
if nil == args.italic then -- nil when |italic= absent or not set or |italic=default; args.italic controls
if ('latn' == subtags.script) or -- script is latn
(this_wiki_lang_tag ~= code and not is_set (subtags.script) and not has_poem_tag (args.text) and
args.italic = 'italic'; -- DEFAULT for {{lang}} templates is upright; but if latn script set for font-style:italic
else
Line 1,297 ⟶ 1,333:
return make_error_msg (msg, args, template);
end
local is_latn_text = unicode.is_Latin (args.text); -- make a boolean
msg = text_script_match_test (subtags.script, is_latn_text)
if msg then -- if an error detected then there is an error message
return make_error_msg (msg, args, template);
end
args.italic, msg = validate_italic (args);
if msg then
Line 1,306 ⟶ 1,349:
if nil == args.italic then -- nil when |italic= absent or not set or |italic=default; args.italic controls
if ('latn' == subtags.script) or -- script is latn
(this_wiki_lang_tag ~= code and not is_set (subtags.script) and
args.italic = 'italic'; -- set font-style:italic
else
Line 1,375 ⟶ 1,418:
table.insert (out, make_text_html (args.code, args.text, tag, args.rtl, args.italic, args.size, ('none' == args.label) and language_name or nil))
if is_set (args.translit) and not
table.insert (out, ', '); -- comma to separate text from translit
if 'none' ~= args.label then
Line 1,543 ⟶ 1,586:
local lang_subtag = args_t.code; -- use only the base language subtag for unsupported tag test; some args_t.code are modified by |script= etc
▲-- return _lang_xx (args_t, templates.langx);
end
|