Module:Lang: Difference between revisions
Content deleted Content added
Johnrdorazio (talk | contribs) m 1 revision imported |
thinsp after lit. per talk |
||
Line 127:
if count > 1 then -- return nil and an error message if more than one is set
return nil, 'only one of
end
Line 412:
local category;
if '
category = '
else
category = '
end
table.insert (out, table.concat ({'
table.insert (out, table.concat ({'<span style=\"font-size: 100%; font-style: normal;\" class=\"error\">
table.insert (out, msg);
table.insert (out, table.concat ({' ([[:Category:', category, ' template errors|help]])'}));
Line 517:
if 'normal' == style then -- when |italic=no
table.insert (html, ' style=\"font-style: normal;'); -- override external markup, if any
style_added = '\"'; -- remember that style attribute added and is not yet closed
end
Line 523:
if is_set (size) then -- when |size=<something>
if is_set (style_added) then
table.insert (html, table.concat ({' font-size: ', size, ';'})); -- add when style attribute already inserted
else
table.insert (html, table.concat ({' style=\"font-size: ', size, ';'})); -- create style attribute
style_added = '\"'; -- remember that style attribute added and is not yet closed
end
Line 535:
table.insert (html, ' collective text'); -- for collective languages
else
table.insert (html, '
end
table.insert (html, '\">'); -- close the opening html tag
Line 561:
for ISO 639-2 collective languages (and for 639-1 bh):
[[Category:Articles with text
]=]
Line 574:
if language_name:find ('languages') then
return table.concat ({'[[Category:Articles with text
end
Line 619 ⟶ 618:
table.insert (tout, "<i lang=\""); -- so use <i> tag
else
table.insert (tout, table.concat ({'<span style=\"font-style: ', style, '\" lang=\"'})); -- non-standard style, construct a span tag for it
end
table.insert (tout, code);
Line 724 ⟶ 723:
if 0 < #maint_msgs then -- when there are maintenance messages
table.insert (maint, table.concat ({'<span class="lang-comment" style="font-style: normal; display: none; color: #33aa33; margin-left: 0.3em;">'})); -- opening <span> tag
for _, msg in ipairs (maint_msgs) do
table.insert (maint, table.concat ({msg, ' '})); -- add message strings
Line 891 ⟶ 890:
local msg; -- for error messages
local tag = 'span'; -- initial value for make_text_html()
local template = args.template or '
validate_cat_args (args); -- determine if categorization should be suppressed▼
if args[1] and args.code then
return make_error_msg ('conflicting: {{{1}}} and
else
args.code = args[1] or args.code; -- prefer args.code
Line 900 ⟶ 901:
if args[2] and args.text then
return make_error_msg ('conflicting: {{{2}}} and
else
args.text = args[2] or args.text; -- prefer args.text
Line 911 ⟶ 912:
args.text, tag = html_tag_select (args.text); -- inspects text; returns appropriate html tag with text trimmed accordingly
▲ validate_cat_args (args); -- determine if categorization should be suppressed
args.rtl = args.rtl == 'yes'; -- convert to boolean: 'yes' -> true, other values -> false
Line 918 ⟶ 917:
args.proto, msg = validate_proto (args.proto); -- return boolean, or nil, or nil and error message flag
if msg then
return make_error_msg (table.concat ({'invalid
end
Line 1,052 ⟶ 1,051:
local msg; -- for error messages
local tag = 'span'; -- initial value for make_text_html()
local template = args.template or '
if args[1] and args.text then
return make_error_msg ('conflicting: {{{1}}} and
else
args.text = args[1] or args.text; -- prefer args.text
Line 1,068 ⟶ 1,067:
if args[2] and args.translit then
return make_error_msg ('conflicting: {{{2}}} and
else
args.translit = args[2] or args.translit -- prefer args.translit
Line 1,074 ⟶ 1,073:
if args[3] and (args.translation or args.lit) then
return make_error_msg ('conflicting: {{{3}}} and
elseif args.translation and args.lit then
return make_error_msg ('conflicting:
else
args.translation = args[3] or args.translation or args.lit; -- prefer args.translation
Line 1,082 ⟶ 1,081:
if args.links and args.link then
return make_error_msg ('conflicting:
else
args.link = args.link or args.links; -- prefer args.link
Line 1,124 ⟶ 1,123:
args.proto, msg = validate_proto (args.proto); -- return boolean, or nil, or nil and error message flag
if msg then
return make_error_msg (table.concat ({'invalid
end
Line 1,158 ⟶ 1,157:
args.text = proto_prefix (args.text, language_name, args.proto); -- prefix proto-language text with a splat
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 unicode.is_Latin (args.text) then -- transliteration (not supported in {{lang}}); not supported when args.text is wholly latn text (this is an imperfect test)
Line 1,195 ⟶ 1,194:
table.insert (out, make_wikilink ('Literal translation', 'lit.'));
end
table.insert (out, "&
end
table.insert (out, table.concat ({''', args.translation, '''})); -- use html entities to avoid wiki markup confusion
Line 1,313 ⟶ 1,312:
local function is_ietf_tag (frame)
return _is_ietf_tag (getArgs (frame)[1]); -- args[1] is the ietf language tag to be tested;
end
--[[--------------------------< I S _ I E T F _ T A G _ F R A M E >--------------------------------------------
Module entry point from an {{#invoke:}}; same as is_ietf_tag() except does not get parameters from the parent
(template) frame. This function not useful when called by {{lang|fn=is_ietf_tag_frame|<tag>}} because <tag>
is in the parent frame.
]]
local function is_ietf_tag_frame (frame)
return _is_ietf_tag (getArgs (frame, {frameOnly = true,})[1]); -- args[1] is the ietf language tag to be tested; do not get parent frame
end
Line 1,341 ⟶ 1,353:
if msg then
local template = (args['template'] and table.concat ({'{{', args['template'], '}}: '})) or ''; -- make template name (if provided by the template)
return table.concat ({'<span style=\"font-size: 100%; font-style: normal;\" class=\"error\">
end
Line 1,405 ⟶ 1,417:
template = table.concat ({'{{', args['template'], '}}: '}); -- make template name (if provided by the template)
end
return table.concat ({'<span style=\"font-size: 100%; font-style: normal;\" class=\"error\">
end
Line 1,442 ⟶ 1,454:
local title_table = lang_data.translit_title_table; -- table of transliteration standards and the language codes and scripts that apply to those standards
local language_name; -- language name that matches language code; used for tool tip
local translit; --
local script; -- IANA script
local msg; -- for when called functions return an error message
Line 1,451 ⟶ 1,463:
if not title_table[args.translit_std] then
return make_error_msg (table.concat ({'unrecognized transliteration standard: ', args.translit_std}), args, '
end
else
Line 1,458 ⟶ 1,470:
else
if args[1] and args[1]:match ('^%a%a%a?%a?$') then -- args[2] missing; is args[1] a code or its it the transliterated text?
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,470 ⟶ 1,482:
args.code = args[1]:lower(); -- use the language/script code; only (2, 3, or 4 alpha characters); 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,496 ⟶ 1,508:
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,536 ⟶ 1,548:
if msg then
local template = (args['template'] and table.concat ({'{{', args['template'], '}}: '})) or ''; -- make template name (if provided by the template)
return table.concat ({'<span style=\"font-size: 100%; font-style: normal;\" class=\"error\">
end
Line 1,567 ⟶ 1,579:
lang_xx_italic = lang_xx_italic,
is_ietf_tag = is_ietf_tag,
is_ietf_tag_frame = is_ietf_tag_frame,
is_lang_name = is_lang_name,
tag_from_name = tag_from_name, -- returns ietf tag associated with language name
Line 1,577 ⟶ 1,590:
_lang_xx_italic = _lang_xx_italic,
_is_ietf_tag = _is_ietf_tag,
get_ietf_parts = get_ietf_parts,
_tag_from_name = _tag_from_name,
_name_from_tag = _name_from_tag,
|