Module:Lang: Difference between revisions
Richardpruen (talk | contribs) m 1 revision imported |
No edit summary |
||
Line 385: | Line 385: | ||
end | end | ||
end | end | ||
else | else -- cheap way to determine if there are prefixes; fonipa and others don't have prefixes; # operator always returns 0 | ||
if not in_array (code, variant_table[variant]['prefixes']) then | if variant_table[variant]['prefixes'][1] and not in_array (code, variant_table[variant]['prefixes']) then | ||
return code, script, region, nil, nil, table.concat ({'unrecognized variant: ', variant, ' for code: ', code}); | return code, script, region, nil, nil, table.concat ({'unrecognized variant: ', variant, ' for code: ', code}); | ||
end | end | ||
end | end | ||
end | end | ||
if is_set (private) then | if is_set (private) then | ||
private = private:lower(); -- ensure that we use and return lower case version of this | private = private:lower(); -- ensure that we use and return lower case version of this | ||
Line 510: | Line 510: | ||
table.insert (html, table.concat ({'<', tag})); -- open the <i>, <span>, or <div> html tag | table.insert (html, table.concat ({'<', tag})); -- open the <i>, <span>, or <div> html tag | ||
code = code:gsub ('%-x%-.*', ''); -- strip private use subtag from code tag because meaningless outside of wikipedia | |||
table.insert (html, table.concat ({' lang="', code, '\"'})); -- add language attribute | table.insert (html, table.concat ({' lang="', code, '\"'})); -- add language attribute | ||
Line 535: | Line 536: | ||
table.insert (html, ' collective text'); -- for collective languages | table.insert (html, ' collective text'); -- for collective languages | ||
else | else | ||
table.insert (html, ' language text'); -- for individual languages | table.insert (html, '-language text'); -- for individual languages | ||
end | end | ||
table.insert (html, '\">'); -- close the opening html tag | table.insert (html, '\">'); -- close the opening html tag | ||
Line 1,157: | Line 1,158: | ||
args.text = proto_prefix (args.text, language_name, args.proto); -- prefix proto-language text with a splat | 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, nil)) | 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) | 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,194: | Line 1,195: | ||
table.insert (out, make_wikilink ('Literal translation', 'lit.')); | table.insert (out, make_wikilink ('Literal translation', 'lit.')); | ||
end | end | ||
table.insert (out, "& | table.insert (out, " </small>"); | ||
end | end | ||
table.insert (out, table.concat ({''', args.translation, '''})); -- use html entities to avoid wiki markup confusion | table.insert (out, table.concat ({''', args.translation, '''})); -- use html entities to avoid wiki markup confusion | ||
Line 1,312: | Line 1,313: | ||
local function is_ietf_tag (frame) | local function is_ietf_tag (frame) | ||
return _is_ietf_tag (getArgs(frame)[1]); -- args[1] is the ietf language tag to be tested; getArgs() | return _is_ietf_tag (getArgs (frame)[1]); -- args[1] is the ietf language tag to be tested; also get parent frame | ||
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 | end | ||
Line 1,441: | Line 1,455: | ||
local title_table = lang_data.translit_title_table; -- table of transliteration standards and the language codes and scripts that apply to those standards | 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 language_name; -- language name that matches language code; used for tool tip | ||
local translit; -- | local translit; -- transliterated text to display | ||
local script; -- IANA script | local script; -- IANA script | ||
local msg; -- for when called functions return an error message | local msg; -- for when called functions return an error message | ||
Line 1,566: | Line 1,580: | ||
lang_xx_italic = lang_xx_italic, | lang_xx_italic = lang_xx_italic, | ||
is_ietf_tag = is_ietf_tag, | is_ietf_tag = is_ietf_tag, | ||
is_ietf_tag_frame = is_ietf_tag_frame, | |||
is_lang_name = is_lang_name, | is_lang_name = is_lang_name, | ||
tag_from_name = tag_from_name, -- returns ietf tag associated with language name | tag_from_name = tag_from_name, -- returns ietf tag associated with language name |