「モジュール:Lang」の版間の差分

編集の要約なし
(1版 をインポートしました)
bsd>Trappist the monk
編集の要約なし
83行目: 83行目:
local category_link = ((0 == namespace or 10 == namespace) and not args_t.nocat) and substitute ('[[Category:$1]]', {category}) or '';
local category_link = ((0 == namespace or 10 == namespace) and not args_t.nocat) and substitute ('[[Category:$1]]', {category}) or '';
return substitute ('[$1] <span style="color:#d33">$2: {{$3}}: $4 ([[:Category:$5|$6]])</span>$7',
return substitute ('[$1] <span style="color:#d33">$2: &#x7B;{$3}}: $4 ([[:Category:$5|$6]])</span>$7', -- &#x7B; prevents template name from being treated as a template call in certain situations
{
{
text or cfg.make_error_msg_t.undefined,
text or cfg.make_error_msg_t.undefined,
146行目: 146行目:
This function attempts to invert the italic markup a args.text by adding/removing leading/trailing italic markup
This function attempts to invert the italic markup a args.text by adding/removing leading/trailing italic markup
in args.text.  Like |italic=unset, |italic=invert disables automatic italic markup.  Individual leading/trailing
in args.text.  Like |italic=unset, |italic=invert disables automatic italic markup.  Individual leading/trailing
apostrophes are converted to their html numeric entity equivalent so that the new italic markup doesn't become
apostrophes are converted to their HTML numeric entity equivalent so that the new italic markup doesn't become
bold markup inadvertently.
bold markup inadvertently.


192行目: 192行目:
Validates |italic= or |italics= assigned values.
Validates |italic= or |italics= assigned values.


When |italic= is set and has an acceptible assigned value, return the matching css font-style property value or,
When |italic= is set and has an acceptable assigned value, return the matching CSS font-style property value or,
for the special case 'default', return nil.
for the special case 'default', return nil.


When |italic= is not set, or has an unacceptible assigned value, return nil and a nil error message.
When |italic= is not set, or has an unacceptable assigned value, return nil and a nil error message.


When both |italic= and |italics= are set, returns nil and a 'conflicting' error message.
When both |italic= and |italics= are set, returns nil and a 'conflicting' error message.


The return value nil causes the calling lang, lang_xx, or transl function to set args.italic according to the template's
The return value nil causes the calling lang, lang_xx, or xlit function to set args.italic according to the template's
defined default ('inherit' for {{lang}}, 'inherit' or 'italic' for {{lang-??}} depending on
defined default ('inherit' for {{lang}}, 'inherit' or 'italic' for {{lang-??}} depending on
the individual template's requirements, 'italic' for {{transliteration}}) or to the value appropriate to |script=, if set ({{lang}}
the individual template's requirements, 'italic' for {{transliteration}}) or to the value appropriate to |script=, if set ({{lang}}
234行目: 234行目:
--[=[--------------------------< V A L I D A T E _ C A T _ A R G S >----------------------------------------------------------
--[=[--------------------------< V A L I D A T E _ C A T _ A R G S >----------------------------------------------------------


Default behavior of the {{lang}} and {{lang-??}} templates is to add categorization when the templates are used in mainspace.
Default behavior of the {{lang}} and {{lang-??}} templates is to add categorization when the templates are used in main space.
This default functionality may be suppressed by setting |nocat=yes or |cat=no.  This function selects one of these two parameters
This default functionality may be suppressed by setting |nocat=yes or |cat=no.  This function selects one of these two parameters
to control categorization.
to control categorization.
285行目: 285行目:
--[[--------------------------< F O R M A T _ I E T F _ T A G >------------------------------------------------
--[[--------------------------< F O R M A T _ I E T F _ T A G >------------------------------------------------


Prettify ietf tags to use recommended subtag formats:
Prettify IETF tags to use recommended subtag formats:
code: lower case
code: lower case
script: sentence case
script: sentence case
352行目: 352行目:


local function get_ietf_parts (source, args_script, args_region, args_variant)
local function get_ietf_parts (source, args_script, args_region, args_variant)
local code, script, region, variant, private; -- ietf tag parts
local code, script, region, variant, private; -- IETF tag parts


if not is_set (source) then
if not is_set (source) then
358行目: 358行目:
end
end


local pattern = { -- table of tables holding acceptibe ietf tag patterns and short names of the ietf part captured by the pattern
local pattern = { -- table of tables holding acceptable IETF tag patterns and short names of the IETF part captured by the pattern
{'^(%a%a%a?)%-(%a%a%a%a)%-(%a%a)%-(%d%d%d%d)$', 's', 'r', 'v'}, -- 1 -  ll-Ssss-RR-variant (where variant is 4 digits)
{'^(%a%a%a?)%-(%a%a%a%a)%-(%a%a)%-(%d%d%d%d)$', 's', 'r', 'v'}, -- 1 -  ll-Ssss-RR-variant (where variant is 4 digits)
{'^(%a%a%a?)%-(%a%a%a%a)%-(%d%d%d)%-(%d%d%d%d)$', 's', 'r', 'v'}, -- 2 -  ll-Ssss-DDD-variant (where region is 3 digits; variant is 4 digits)
{'^(%a%a%a?)%-(%a%a%a%a)%-(%d%d%d)%-(%d%d%d%d)$', 's', 'r', 'v'}, -- 2 -  ll-Ssss-DDD-variant (where region is 3 digits; variant is 4 digits)
388行目: 388行目:
}
}


local t = {}; -- table of captures; serves as a translator between captured ietf tag parts and named variables
local t = {}; -- table of captures; serves as a translator between captured IETF tag parts and named variables


for i, v in ipairs (pattern) do -- spin through the pattern table looking for a match
for i, v in ipairs (pattern) do -- spin through the pattern table looking for a match
402行目: 402行目:
};
};
script = t.s or ''; -- translate table contents to named variables;
script = t.s or ''; -- translate table contents to named variables;
region = t.r or ''; -- absent table entries are nil so set named ietf parts to empty string for concatenation
region = t.r or ''; -- absent table entries are nil so set named IETF parts to empty string for concatenation
variant= t.v or '';
variant= t.v or '';
private = t.p or '';
private = t.p or '';
436行目: 436行目:
script = script:lower(); -- ensure that we use and return lower case version of this
script = script:lower(); -- ensure that we use and return lower case version of this
if not script_table[script] then
if not script_table[script] then
return code, nil, nil, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_scr_code, {script, code}); -- language code ok, invalid script, don't know about the others (don't care?)
return code, nil, nil, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_scr_code, {script, code}); -- language code OK, invalid script, don't know about the others (don't care?)
end
end
end
end
if suppressed_table[script] then -- ensure that code-script does not use a suppressed script
if suppressed_table[script] then -- ensure that code-script does not use a suppressed script
if in_array (code, suppressed_table[script]) then
if in_array (code, suppressed_table[script]) then
return code, nil, nil, nil, nil, substitute (cfg.get_ietf_parts_t.script_code, {script, code}); -- language code ok, script is suppressed for this code
return code, nil, nil, nil, nil, substitute (cfg.get_ietf_parts_t.script_code, {script, code}); -- language code OK, script is suppressed for this code
end
end
end
end
537行目: 537行目:


if text:find ('\n+') then -- look for any number of \n characters in text
if text:find ('\n+') then -- look for any number of \n characters in text
text = text:gsub ('([^\n])\n([^\n])', '%1 %2'); -- replace single newline characters with a space character which mimics mediawiki
text = text:gsub ('([^\n])\n([^\n])', '%1 %2'); -- replace single newline characters with a space character which mimics MediaWiki


if 'italic' == style then
if 'italic' == style then
text = text:gsub('[^\n]+', '<p><i>%1</i></p>'); -- insert p and italic markup tags at each impled p (two or more consecutive '\n\n' sequences)
text = text:gsub('[^\n]+', '<p><i>%1</i></p>'); -- insert p and italic markup tags at each implied p (two or more consecutive '\n\n' sequences)
else
else
text = text:gsub ('[^\n]+', '<p>%1</p>'); -- insert p markup at each impled p
text = text:gsub ('[^\n]+', '<p>%1</p>'); -- insert p markup at each implied p
text = text:gsub ('\n', ''); -- strip newline characters
text = text:gsub ('\n', ''); -- strip newline characters
end
end
555行目: 555行目:
Makes a <span title="<title text>"><content_text></span> or <div title="<title text>"><content_text></div> where
Makes a <span title="<title text>"><content_text></span> or <div title="<title text>"><content_text></div> where
<title text> is in the tool-tip in the wiki's local language and <content_text> is non-local-language text in
<title text> is in the tool-tip in the wiki's local language and <content_text> is non-local-language text in
html markup.  This because the lang= attibute applies to the content of its enclosing tag.
HTML markup.  This because the lang= attribute applies to the content of its enclosing tag.


<tag> holds a string 'div' or 'span' used to choose the correct wrapping tag.
<tag> holds a string 'div' or 'span' used to choose the correct wrapping tag.
577行目: 577行目:
--[[--------------------------< M A K E _ T E X T _ H T M L >--------------------------------------------------
--[[--------------------------< M A K E _ T E X T _ H T M L >--------------------------------------------------


Add the html markup to text according to the type of content that it is: <span> or <i> tags for inline content or
Add the HTML markup to text according to the type of content that it is: <span> or <i> tags for inline content or
<div> tags for block content
<div> tags for block content


600行目: 600行目:
end
end


if 'span' == tag then -- default html tag for inline content
if 'span' == tag then -- default HTML tag for inline content
if 'italic' == style then -- but if italic
if 'italic' == style then -- but if italic
tag = 'i'; -- change to <i> tags
tag = 'i'; -- change to <i> tags
608行目: 608行目:
end
end


table.insert (html_t, table.concat ({'<', tag})); -- open the <i>, <span>, or <div> html tag
table.insert (html_t, 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
code = code:gsub ('%-x%-.*', ''); -- strip private use subtag from code tag because meaningless outside of Wikipedia
table.insert (html_t, table.concat ({' lang="', code, '\"'})); -- add language attribute
table.insert (html_t, table.concat ({' lang="', code, '\"'})); -- add language attribute


632行目: 632行目:
end
end


table.insert (html_t, table.concat ({style_added, '>'})); -- close the opening html tag
table.insert (html_t, table.concat ({style_added, '>'})); -- close the opening HTML tag
table.insert (html_t, text); -- insert the text
table.insert (html_t, text); -- insert the text


table.insert (html_t, table.concat ({'</', tag, '>'})); -- close the 'text' <i>, <span>, or <div> html tag
table.insert (html_t, table.concat ({'</', tag, '>'})); -- close the 'text' <i>, <span>, or <div> HTML tag


if is_set (language) then -- create a <title_text> string for the title= attribute in a wrapper span or div
if is_set (language) then -- create a <title_text> string for the title= attribute in a wrapper span or div
704行目: 704行目:
to be |translit-script= (in this function, tscript).
to be |translit-script= (in this function, tscript).


This function is used by both lang_xx() and transl()
This function is used by both lang_xx() and xlit()
lang_xx() always provides code, language_name, and translit; may provide tscript; never provides style
lang_xx() always provides code, language_name, and translit; may provide tscript; never provides style
transl() always provides language_name, translit, and one of code or tscript, never both; always provides style
xlit() always provides language_name, translit, and one of code or tscript, never both; always provides style


For {{transliteration}}, style only applies when a language code is provided.
For {{transliteration}}, style only applies when a language code is provided.
749行目: 749行目:
if not title_t[std] then return ''; end -- invalid standard, setup for error message
if not title_t[std] then return ''; end -- invalid standard, setup for error message
if title_t[std][code] then -- if language code is in the table (transl may not provide a language code)
if title_t[std][code] then -- if language code is in the table (xlit may not provide a language code)
title_text = substitute ('$1$2 ($3 $4) $5', { -- add the appropriate text to the tool tip
title_text = substitute ('$1$2 ($3 $4) $5', { -- add the appropriate text to the tool tip
title_text,
title_text,
913行目: 913行目:
--[[--------------------------< H T M L _ T A G _ S E L E C T >------------------------------------------------
--[[--------------------------< H T M L _ T A G _ S E L E C T >------------------------------------------------


Inspects content of and selectively trims text.  Returns text and the name of an appropriate html tag for text.
Inspects content of and selectively trims text.  Returns text and the name of an appropriate HTML tag for text.


If text contains:
If text contains:
992行目: 992行目:
elseif override_table[code] then -- not there so try basic language tag
elseif override_table[code] then -- not there so try basic language tag
name = override_table[code];
name = override_table[code];
elseif lang_table[code] then -- shift to iana active tag/name table
elseif lang_table[code] then -- shift to IANA active tag/name table
name = lang_table[code];
name = lang_table[code];
elseif lang_dep_table[code] then -- try the iana deprecated tag/name table
elseif lang_dep_table[code] then -- try the IANA deprecated tag/name table
name = lang_dep_table[code];
name = lang_dep_table[code];
end
end
1,093行目: 1,093行目:


TODO: when text has accept-as-written markup, return a non-boolean value to indicate that <text> is not wholly
TODO: when text has accept-as-written markup, return a non-boolean value to indicate that <text> is not wholly
latn script?  Use that return value to create non-Latn html lang= attribute because <text> isn't really
latn script?  Use that return value to create non-Latn HTML lang= attribute because <text> isn't really
latn so lang=und (undetermined)? or instead, omit the -Latn subtag? (without -latn need to force |italic=yes)
latn so lang=und (undetermined)? or instead, omit the -Latn subtag? (without -Latn need to force |italic=yes)


]]
]]
1,162行目: 1,162行目:
end
end
args.text, tag = html_tag_select (args.text); -- inspects text; returns appropriate html tag with text trimmed accordingly
args.text, tag = html_tag_select (args.text); -- inspects text; returns appropriate HTML tag with text trimmed accordingly


args.rtl = args.rtl == cfg.keywords_t.affirmative; -- convert to boolean: 'yes' -> true, other values -> false
args.rtl = args.rtl == cfg.keywords_t.affirmative; -- convert to boolean: 'yes' -> true, other values -> false
1,208行目: 1,208行目:


args.code = format_ietf_tag (code, subtags.script, subtags.region, subtags.variant, subtags.private); -- format to recommended subtag styles
args.code = format_ietf_tag (code, subtags.script, subtags.region, subtags.variant, subtags.private); -- format to recommended subtag styles
language_name = language_name_get (args.code, code, true); -- get language name; try ietf tag first, then code w/o variant then code w/ variant
language_name = language_name_get (args.code, code, true); -- get language name; try IETF tag first, then code w/o variant then code w/ variant


if cfg.keywords_t.invert == args.italic and 'span' == tag then -- invert only supported for in-line content
if cfg.keywords_t.invert == args.italic and 'span' == tag then -- invert only supported for in-line content
1,273行目: 1,273行目:


if 'none' ~= args_t.label then -- if we want a label
if 'none' ~= args_t.label then -- if we want a label
table.insert (translation_t, '<small>'); -- open the <small> html tag
table.insert (translation_t, '<small>'); -- open the <small> HTML tag
if cfg.keywords_t.negative == args_t.link then
if cfg.keywords_t.negative == args_t.link then
table.insert (translation_t, substitute ('<abbr title="$1">$2</abbr>', {cfg.translation_make_t.lit_xlation, cfg.translation_make_t.lit_abbr})); -- unlinked form
table.insert (translation_t, substitute ('<abbr title="$1">$2</abbr>', {cfg.translation_make_t.lit_xlation, cfg.translation_make_t.lit_abbr})); -- unlinked form
1,279行目: 1,279行目:
table.insert (translation_t, make_wikilink (cfg.translation_make_t.lit_xlation, cfg.translation_make_t.lit_abbr)); -- linked form
table.insert (translation_t, make_wikilink (cfg.translation_make_t.lit_xlation, cfg.translation_make_t.lit_abbr)); -- linked form
end
end
table.insert (translation_t, "&thinsp;</small>"); -- close the <small> html tag
table.insert (translation_t, "&thinsp;</small>"); -- close the <small> HTML tag
end
end
table.insert (translation_t, table.concat ({'&#39;', args_t.translation, '&#39;'})); -- use html entities to avoid wiki markup confusion
table.insert (translation_t, table.concat ({'&#39;', args_t.translation, '&#39;'})); -- use HTML entities to avoid wiki markup confusion
return table.concat (translation_t); -- make a big string and done
return table.concat (translation_t); -- make a big string and done
end
end
1,330行目: 1,330行目:
]]
]]


local function _lang_xx (args, base_template) -- base_template will be either of 'Langx' or 'Lang-xx'
local function _lang_xx (args, base_template) -- base_template will be either of 'langx' or 'lang-xx'
local out = {};
local out = {};
local language_name; -- used to make display text, article links
local language_name; -- used to make display text, article links
1,361行目: 1,361行目:
end
end


args.text, tag = html_tag_select (args.text); -- inspects text; returns appropriate html tag with text trimmed accordingly
args.text, tag = html_tag_select (args.text); -- inspects text; returns appropriate HTML tag with text trimmed accordingly


if args[translit_idx] and args.translit then
if args[translit_idx] and args.translit then
1,455行目: 1,455行目:


args.code = format_ietf_tag (code, subtags.script, subtags.region, subtags.variant, subtags.private); -- format to recommended subtag styles
args.code = format_ietf_tag (code, subtags.script, subtags.region, subtags.variant, subtags.private); -- format to recommended subtag styles
language_name = language_name_get (args.code, code, true); -- get language name; try ietf tag first, then code w/o variant then code w/ variant
language_name = language_name_get (args.code, code, true); -- get language name; try IETF tag first, then code w/o variant then code w/ variant


category_name = language_name; -- category names retain IANA parenthetical diambiguators (if any)
category_name = language_name; -- category names retain IANA parenthetical diambiguators (if any)
1,470行目: 1,470行目:
if mw.ustring.find (language_name, 'languages', 1, true) then
if mw.ustring.find (language_name, 'languages', 1, true) then
table.insert (out, make_wikilink (language_name)); -- collective language name uses simple wikilink
table.insert (out, make_wikilink (language_name)); -- collective language name uses simple wikilink
elseif lang_data.article_name[args.code:lower()] then -- is ietf tag in article name over ride?
elseif lang_data.article_name[args.code:lower()] then -- is IETF tag in article name over ride?
table.insert (out, make_wikilink (lang_data.article_name[args.code:lower()], language_name)); -- language name with wikilink from override data
table.insert (out, make_wikilink (lang_data.article_name[args.code:lower()], language_name)); -- language name with wikilink from override data
elseif lang_data.article_name[code] then -- is language tag in article override
elseif lang_data.article_name[code] then -- is language tag in article override
1,669行目: 1,669行目:


|  1 |  2 |  3 |  4
|  1 |  2 |  3 |  4
{{lang-xx |<text> |<transl> |<xlate> }}
{{lang-xx |<text> |<xlit> |<xlat> }}
{{langx |<tag> |<text> |<transl> |<xlate> }}
{{langx |<tag> |<text> |<xlit> |<xlat> }}


The calls to lang_xx_args_get() and _lang_xx() use 'Langx' as a flag for those functions to select the proper
The calls to lang_xx_args_get() and _lang_xx() use 'langx' as a flag for those functions to select the proper
positional parameters.
positional parameters.


1,678行目: 1,678行目:


{{langx}} can't do that.  The initial version of {{langx}} relied on a list of language tags (inherit_t in ~/langx)
{{langx}} can't do that.  The initial version of {{langx}} relied on a list of language tags (inherit_t in ~/langx)
scraped from those {{lang-??}} templates that call lang_xx_inherit() to render text in upright font. Langx now
scraped from those {{lang-??}} templates that call lang_xx_inherit() to render text in upright font. langx() now
uses auto-italics code adapted from {{lang}} (doesn't support poem tags).
uses auto-italics code adapted from {{lang}} (doesn't support poem tags).


1,684行目: 1,684行目:


local function langx (frame)
local function langx (frame)
local args_t = lang_xx_args_get (frame, cfg.templates_t.langx); -- get the arguments; 'Langx' is the <base_template> used to decide which positional param is 'text', 'translit', 'lit'
local args_t = lang_xx_args_get (frame, cfg.templates_t.langx); -- get the arguments; 'langx' is the <base_template> used to decide which positional param is 'text', 'translit', 'lit'
return _langx (args_t);
return _langx (args_t);
1,715行目: 1,715行目:


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; also get parent frame
return _is_ietf_tag (getArgs (frame)[1]); -- args[1] is the IETF language tag to be tested; also get parent frame
end
end


1,728行目: 1,728行目:


local function is_ietf_tag_frame (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
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


1,760行目: 1,760行目:


raw_code = format_ietf_tag (code, subtags.script, subtags.region, subtags.variant, subtags.private); -- format to recommended subtag styles; private omitted because private
raw_code = format_ietf_tag (code, subtags.script, subtags.region, subtags.variant, subtags.private); -- format to recommended subtag styles; private omitted because private
language_name = language_name_get (raw_code, code); -- get language name; try ietf tag first, then code w/o variant then code w/ variant
language_name = language_name_get (raw_code, code); -- get language name; try IETF tag first, then code w/o variant then code w/ variant


if 'yes' ~= args.raw then
if 'yes' ~= args.raw then
1,769行目: 1,769行目:
if mw.ustring.find (language_name, 'languages', 1, true) then
if mw.ustring.find (language_name, 'languages', 1, true) then
language_name = make_wikilink (language_name, label); -- collective language name uses simple wikilink
language_name = make_wikilink (language_name, label); -- collective language name uses simple wikilink
elseif lang_data.article_name[raw_code:lower()] then -- is ietf tag in article name override?
elseif lang_data.article_name[raw_code:lower()] then -- is IETF tag in article name override?
language_name = make_wikilink (lang_data.article_name[raw_code:lower()], label or language_name); -- language name with wikilink from override data
language_name = make_wikilink (lang_data.article_name[raw_code:lower()], label or language_name); -- language name with wikilink from override data
elseif lang_data.article_name[code] then -- is language tag in article name override?
elseif lang_data.article_name[code] then -- is language tag in article name override?
1,788行目: 1,788行目:
]]
]]


local function name_from_tag (frame) -- entry point from an {{#invoke:Lang|name_from_tag|<ietf tag>|link=<yes>|template=<template name>}}
local function name_from_tag (frame) -- entry point from an {{#invoke:lang|name_from_tag|<IETF tag>|link=<yes>|template=<template name>}}
return _name_from_tag (getArgs(frame)) -- pass-on the args table, nothing else; getArgs() so we also get parent frame
return _name_from_tag (getArgs(frame)) -- pass-on the args table, nothing else; getArgs() so we also get parent frame
end
end
1,795行目: 1,795行目:
--[[--------------------------< _ T A G _ F R O M _ N A M E >--------------------------------------------------
--[[--------------------------< _ T A G _ F R O M _ N A M E >--------------------------------------------------


Returns the ietf language tag associated with the language name.  Spelling of language name must be correct
Returns the IETF language tag associated with the language name.  Spelling of language name must be correct
according to the spelling in the source tables.  When a standard language name has a parenthetical disambiguator,
according to the spelling in the source tables.  When a standard language name has a parenthetical disambiguator,
that disambiguator must be omitted (they are not present in the data name-to-tag tables).
that disambiguator must be omitted (they are not present in the data name-to-tag tables).
1,835行目: 1,835行目:
]]
]]


local function tag_from_name (frame) -- entry point from an {{#invoke:Lang|tag_from_name|<language name>|link=<yes>|template=<template name>}}
local function tag_from_name (frame) -- entry point from an {{#invoke:lang|tag_from_name|<language name>|link=<yes>|template=<template name>}}
local result, _ = _tag_from_name (getArgs(frame)) -- pass-on the args table, nothing else; getArgs() so we also get parent frame; supress second return used by is_lang_name()
local result, _ = _tag_from_name (getArgs(frame)) -- pass-on the args table, nothing else; getArgs() so we also get parent frame; supress second return used by is_lang_name()
return result;
return result;
1,853行目: 1,853行目:




--[[--------------------------< _ T R A N S L >----------------------------------------------------------------
--[[--------------------------< _ X L I T >--------------------------------------------------------------------


Module entry point from another module.
Module entry point from another module.
1,859行目: 1,859行目:
]]
]]


local function _transl (args)
local function _xlit (args)
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
1,891行目: 1,891行目:
end
end


if is_set (args[1]) then -- IANA language code used for html lang= attribute; or ISO 15924 script code
if is_set (args[1]) then -- IANA language code used for HTML lang= attribute; or ISO 15924 script code
if args[1]:match ('^%a%a%a?%a?$') or args[1]:match ('^%a%a%a?%-x%-') then -- args[1] has correct form?
if args[1]:match ('^%a%a%a?%a?$') or args[1]:match ('^%a%a%a?%-x%-') then -- args[1] has correct form?
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
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
1,938行目: 1,938行目:




--[[--------------------------< T R A N S L >------------------------------------------------------------------
--[[--------------------------< X L I T >----------------------------------------------------------------------


Module entry point from an {{#invoke:}}.
Module entry point from an {{#invoke:}}.
1,944行目: 1,944行目:
]]
]]


local function transl (frame)
local function xlit (frame)
return _transl (getArgs(frame));
return _xlit (getArgs(frame));
end
end


1,975行目: 1,975行目:


raw_code = format_ietf_tag (code, subtags.script, subtags.region, subtags.variant, subtags.private); -- format to recommended subtag styles; private omitted because private
raw_code = format_ietf_tag (code, subtags.script, subtags.region, subtags.variant, subtags.private); -- format to recommended subtag styles; private omitted because private
category_name = language_name_get (raw_code, code); -- get language name; try ietf tag first, then code w/o variant then code w/ variant
category_name = language_name_get (raw_code, code); -- get language name; try IETF tag first, then code w/o variant then code w/ variant
category_name = make_category (code, category_name, nil, true):gsub ('[%[%]]', '');
category_name = make_category (code, category_name, nil, true):gsub ('[%[%]]', '');


1,992行目: 1,992行目:
]]
]]


local function category_from_tag (frame) -- entry point from an {{#invoke:Lang|category_from_tag|<ietf tag>|template=<template name>}}
local function category_from_tag (frame) -- entry point from an {{#invoke:lang|category_from_tag|<IETF tag>|template=<template name>}}
return _category_from_tag (getArgs (frame)); -- pass-on the args table, nothing else; getArgs() so we also get parent frame
return _category_from_tag (getArgs (frame)); -- pass-on the args table, nothing else; getArgs() so we also get parent frame
end
end
2,001行目: 2,001行目:


return {
return {
category_from_tag = category_from_tag,
category_from_tag = category_from_tag, -- frame entry points when this module is #invoke:ed into templates/wikitext
lang = lang, -- entry point for {{lang}}
lang = lang, -- entry point for {{lang}}
langx = langx, -- entry point for {{langx}}
langx = langx, -- entry point for {{langx}}
2,009行目: 2,009行目:
is_ietf_tag_frame = is_ietf_tag_frame,
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
name_from_tag = name_from_tag, -- used for template documentation; possible use in ISO 639 name from code templates
name_from_tag = name_from_tag, -- used for template documentation; possible use in ISO 639 name from code templates
transl = transl, -- entry point for {{transliteration}}
xlit = xlit, -- entry point for {{transliteration}}
_category_from_tag = _category_from_tag, -- entry points when this module is require()d into other modules
_category_from_tag = _category_from_tag, -- API entry points when this module is require()d into other modules
_lang = _lang,
_lang = _lang,
_langx = _langx,
_langx = _langx,
2,022行目: 2,022行目:
_tag_from_name = _tag_from_name,  
_tag_from_name = _tag_from_name,  
_name_from_tag = _name_from_tag,
_name_from_tag = _name_from_tag,
_transl = _transl,
_xlit = _xlit,
_translation_make = translation_make,
_translation_make = translation_make,
};
};
匿名利用者