Bureaucrats, rtl-contributors, Administrators
1,619
edits
m (1 revision imported from wikipedia:Module:Lang) |
m (1 revision imported) |
||
(One intermediate revision by one other user not shown) | |||
Line 1:
--[=[
Lua support for the {{lang}}, {{lang-xx}}, and {{
]=]
Line 105:
The return value nil causes the calling lang, lang_xx, or transl function to set args.italic according to the template's
defined default ('inherit' for {{lang}}, 'inherit' or 'italic' for {{lang-xx}} depending on
the individual template's requirements, 'italic' for {{
and {{lang-xx}} only).
Line 414:
local category;
if '
category = '
else
category = 'Lang and lang-xx'
Line 632:
return translit <i lang=xx-Latn>...</i> where xx is the language code; else return empty string
The value |script= is not used in {{
are listed in the {{
at {{Language with name and transliteration}}. If |script= is set, this function uses it in preference to code.
Line 643:
transl() always provides language_name, translit, and one of code or tscript, never both; always provides style
For {{
]]
Line 705:
local close_tag;
if is_set (code) then -- when a language code is provided (always with {{lang-xx}} templates, not always with {{
code = code:match ('^(%a%a%a?)'); -- strip all subtags leaving only the language subtag
Line 718:
table.insert (out_t, "-Latn\">"); -- transliterations are always Latin script
else
table.insert (out_t, "<span>"); -- when no language code: no lang= attribute, not italic ({{
close_tag = '</span>';
end
Line 840:
If text contains <poem>...</poem> stripmarker, return text unmodified and choose <div>..</div> tags because
the stripmarker is replaced with text wrapped in <div>..</div> tags.
If the text contains any actual <div>...</div> tags, then it's again returned unmodified and <div>...</div>
tags are used to wrap it, to prevent div/span inversion.
]]
Line 848 ⟶ 851:
if has_poem_tag (text) then -- contains poem stripmarker (we can't know the content of that)
tag = 'div'; -- poem replacement is in div tags so lang must use div tags
elseif text:find ('<div') then -- reductive; if the text contains a div tag, we must use div tags
tag = 'div';
elseif mw.text.trim (text):find ('\n\n+') then -- contains implied p tags
text = mw.text.trim (text); -- trim leading and trailing whitespace characters
Line 1,527 ⟶ 1,532:
maint_msgs = {};
if is_set (args[3]) then -- [3] set when {{
args.text = args[3]; -- get the transliterated text
args.translit_std = args[2] and args[2]:lower(); -- get the standard; lower case for table indexing
if not title_table[args.translit_std] then
return make_error_msg (table.concat ({'unrecognized transliteration standard: ', args.translit_std}), args, '
end
else
if is_set (args[2]) then -- [2] set when {{
args.text = args[2]; -- get the transliterated text
else
if args[1] and (args[1]:match ('^%a%a%a?%a?$') or -- args[2] missing; is args[1] a language or script tag or is it the transliterated text?
args[1]:match ('^%a%a%a?%-x%-')) then -- or is args[1] a private-use tag
return make_error_msg ('no text', args, '
else
args.text = args[1]; -- args[1] is not a code so we're missing that; assign args.text for error message
return make_error_msg ('missing language / script code', args, '
end
end
Line 1,552 ⟶ 1,557:
args.code = args[1]:lower(); -- use the language/script code; only (2, 3, or 4 alpha characters) or private-use; lower case because table indexes are lower case
else
return make_error_msg (table.concat ({'unrecognized language / script code: ', args[1]}), args, '
end
else
return make_error_msg ('missing language / script code', args, '
end
args.italic, msg = validate_italic (args);
if msg then
return make_error_msg (msg, args, '
end
Line 1,579 ⟶ 1,584:
args.code = ''; -- unset because not a language code
else
return make_error_msg (table.concat ({'unrecognized language / script code: ', args.code}), args, '
end
-- here only when all parameters passed to make_translit() are valid
Line 1,658 ⟶ 1,663:
tag_from_name = tag_from_name, -- returns ietf tag associated with language name
name_from_tag = name_from_tag, -- used for template documentation; possible use in ISO 639 name from code templates
transl = transl, -- entry point for {{
_category_from_tag = _category_from_tag, -- entry points when this module is require()d into other modules
|