Content deleted Content added
sync from sandbox; |
sync from sandbox; |
||
Line 41:
]]
local function
return table.concat ({'<span style="color:#d33">', cfg.misc_text_t.error, ': ', template, msg, '</span>'})
end
Line 48:
--[[--------------------------< S U B S T I T U T E >----------------------------------------------------------
<data_t> not nil; returns <message> else.
]]
Line 60:
--[[--------------------------< M A K E _ E R R O R _ M S G >--------------------------------------------------
]]
Line 94:
--[[--------------------------< P A R A M E T E R _ V A L I D A T E >------------------------------------------
]]
Line 186 ⟶ 187:
--[[--------------------------< V A L I D A T E _ I T A L I C >------------------------------------------------
When |italic= is set and has an acceptible assigned value, return the matching css font-style property value or,
Line 262 ⟶ 263:
--[[--------------------------< I N _ A R R A Y >--------------------------------------------------------------
Whether needle is in haystack.
]]
Line 281 ⟶ 282:
--[[--------------------------< F O R M A T _ I E T F _ T A G >------------------------------------------------
code: lower case
script: sentence case
Line 317 ⟶ 318:
--[[--------------------------< G E T _ I E T F _ P A R T S >--------------------------------------------------
primary language subtag (required) - 2 or 3 character IANA language code
script subtag - four character IANA script code
Line 331 ⟶ 332:
lang-x-private
each of lang, script, region, variant, and private, when used, must be valid.
Languages with both two- and three-character code synonyms are promoted to the two-character synonym because
Line 338 ⟶ 339:
For {{lang-??}} templates, the parameters |script=, |region=, and |variant= are supported (not supported in {{lang}}
because those parameters are superfluous to the IETF subtags in |code=).
parts are returned as nil; the sixth returned item is an error message (if an error detected) or nil.
]]
Line 519 ⟶ 520:
--[[--------------------------< D I V _ M A R K U P _ A D D >--------------------------------------------------
]]
local function div_markup_add (text, style)
if text:find ('^\n[%*:;#]') then -- look for list markup; list markup must begin at start of text
if 'italic' == style then
Line 551 ⟶ 550:
--[[--------------------------< T I T L E _ W R A P P E R _ M A K E >------------------------------------------
<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.
<tag> holds a string 'div' or 'span' used to choose the correct wrapping tag.
]]
Line 656:
[[Category:Articles containing <language>-language text]]
[[Category:Articles containing explicitly cited English-language text]]
[[Category:Articles with text in <language> languages]]
Line 665:
local function make_category (code, language_name, nocat, name_get)
if ((0 ~= namespace) or nocat) and not name_get then -- only categorize in article space
return ''; -- return empty string for concatenation
Line 695 ⟶ 692:
--[[--------------------------< M A K E _ T R A N S L I T >----------------------------------------------------
The value |script= is not used in {{transliteration}} for this purpose; instead it uses |code. Because language scripts
Line 702 ⟶ 699:
To avoid confusion, in this module and the templates that use it, the transliteration script parameter is renamed
to be |translit-script= (in this function, tscript).
This function is used by both lang_xx() and transl()
Line 708 ⟶ 705:
transl() 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.
]]
local function make_translit (code, language_name, translit, std, tscript, style, engvar)
local title_t = lang_data.translit_title_table; -- table of transliteration standards and the language codes and scripts that apply to those standards
local title_text = ''; -- tool tip text for title= attribute
Line 796 ⟶ 792:
end
local
if is_set (code) then -- when a language code is provided (always with {{lang-??}} templates, not always with {{transliteration}})
code = code:match ('^(%a%a%a?)'); -- strip all subtags leaving only the language subtag
if not style then -- nil for the default italic style
else
tag = string.format(tag, style, "%s", "%s")
end
else
end
if '' == title_text then -- when there is no need for a tool-tip
return
else
title_text =
return title_wrapper_make (title_text,
end
end
Line 829 ⟶ 819:
This function checks the content of args.text and returns empty string if nothing is amiss else it returns an
error message.
Italic rendering is controlled by the |italic= template parameter so italic markup should never appear in args.text
Line 838 ⟶ 828:
local function validate_text (template, args)
if not is_set (args.text) then
return make_error_msg (
end
Line 857 ⟶ 847:
--[[--------------------------< R E N D E R _ M A I N T >------------------------------------------------------
]]
Line 884 ⟶ 874:
--[[--------------------------< P R O T O _ P R E F I X >------------------------------------------------------
will be rendered outside of italic markup (if used).
do nothing.
proto_param is boolean or nil; true adds splat prefix regardless of language name; false removes and
regardless of language name; nil does nothing; presumes that the value in text is correct but removes extra splac.
]]
Line 906 ⟶ 896:
--[[--------------------------< H A S _ P O E M _ T A G >------------------------------------------------------
the content that will replace the stripmarker.
Line 963 ⟶ 953:
--[[--------------------------< V A L I D A T E _ P R O T O >--------------------------------------------------
empty string (or parameter omitted) returns as nil; any other value returns nil with <proto_param> as second
return value for use in error message.
Line 984 ⟶ 974:
--[[--------------------------< L A N G U A G E _ N A M E _ G E T >--------------------------------------------
]]
Line 1,022 ⟶ 1,012:
Conversely, when <text> is written using the Latn script, the IETF script subtag, if present, should be Latn.
]]
local function text_script_match_test (script, is_latn_text, pos)
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 cfg.text_script_match_test_t.latn_txt_mismatch;
end
else -- when text is not wholly Latn script
if ('Latn' == script or 'latn' == script) then -- but Latn script is specified
return substitute (cfg.text_script_match_test_t.latn_scr_mismatch, {pos});
end
end
Line 1,042 ⟶ 1,033:
--[[--------------------------< I S _ L A T I N >--------------------------------------------------------------
in certain romanizations. This function attempts to discover if <text> script is Latn with Greek 'θ' or some
other script with Greek 'θ'.
Line 1,075 ⟶ 1,066:
--[[--------------------------< _ L A N G >--------------------------------------------------------------------
<includeonly>{{#invoke:lang|lang}}</includeonly>
]]
Line 1,100 ⟶ 1,091:
if args[1] and args.code then
return make_error_msg (substitute (cfg.lang_t.conflict_n_param, {'1',
else
args.code = args[1] or args.code; -- prefer args.code
Line 1,106 ⟶ 1,097:
if args[2] and args.text then
return make_error_msg (substitute (cfg.lang_t.conflict_n_param, {'2',
else
args.text = args[2] or args.text; -- prefer args.text
Line 1,131 ⟶ 1,122:
end
local is_latn_text, pos = is_latin (args.text, subtags.script);
msg = text_script_match_test (subtags.script, is_latn_text, pos)
if msg then -- if an error detected then there is an error message
return make_error_msg (msg, args, template);
Line 1,179 ⟶ 1,170:
--[[--------------------------< L A N G >----------------------------------------------------------------------
<includeonly>{{#invoke:lang|lang}}</includeonly>
]]
Line 1,216 ⟶ 1,207:
--[[--------------------------< T R A N S L A T I O N _ M A K E >----------------------------------------------
Also used by {{lang-x2}}.
]]
Line 1,304 ⟶ 1,295:
if args[text_idx] and args.text then
return make_error_msg (substitute (cfg.lang_t.conflict_n_param, {translit_idx,
else
args.text = args[text_idx] or args.text; -- prefer positional 'text' parameter
Line 1,317 ⟶ 1,308:
if args[translit_idx] and args.translit then
return make_error_msg (substitute (cfg.lang_t.conflict_n_param, {translit_idx,
else
Line 1,333 ⟶ 1,324:
if args[xlate_idx] and (args.translation or args.lit) then
return make_error_msg (substitute (cfg.lang_xx_t.conflict_n_lit, {translit_idx
elseif args.translation and args.lit then
return make_error_msg (cfg.lang_xx_t.conflict_lit, args, template);
Line 1,402 ⟶ 1,393:
args.proto, msg = validate_proto (args.proto); -- return boolean, or nil, or nil and error message flag
if msg then
return make_error_msg (
end
Line 1,483 ⟶ 1,474:
--[[--------------------------< L A N G _ X X _ A R G S _ G E T >----------------------------------------------
]]
Line 1,514 ⟶ 1,505:
--[[--------------------------< L A N G _ X X _ I T A L I C >--------------------------------------------------
Entry point for those {{lang-??}} templates that call lang_xx_italic().
]]
Line 1,534 ⟶ 1,525:
--[[--------------------------< _ L A N G _ X X _ I T A L I C >------------------------------------------------
Entry point from another module.
]]
Line 1,546 ⟶ 1,537:
--[[--------------------------< L A N G _ X X _ I N H E R I T >------------------------------------------------
Entry point for those {{lang-??}} templates that call lang_xx_inherit().
]]
Line 1,566 ⟶ 1,557:
--[[--------------------------< _ L A N G _ X X _ I N H E R I T >----------------------------------------------
Entry point from another module.
]]
Line 1,613 ⟶ 1,604:
Entry point for {{langx}}.
this function calls _lang_xx() to render non-English text.
but {{langx}} has four:
Line 1,626 ⟶ 1,617:
{{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.
uses auto-italics code adapted from {{lang}} (doesn't support poem tags).
]]
Line 1,644 ⟶ 1,635:
All code combinations supported by {{lang}} and the {{lang-??}} templates are supported by this function.
Module entry point from another module.
]]
Line 1,658 ⟶ 1,649:
--[[--------------------------< I S _ I E T F _ T A G >--------------------------------------------------------
Module entry point from an {{#invoke:}}.
]]
Line 1,688 ⟶ 1,679:
Set invoke's |link= parameter to yes to get wikilinked version of the language name.
Module entry point from another module.
]]
Line 1,704 ⟶ 1,695:
if msg then
local template = (args['template'] and table.concat ({'{{', args['template'], '}}: '})) or ''; -- make template name (if provided by the template)
return
end
Line 1,730 ⟶ 1,721:
--[[--------------------------< N A M E _ F R O M _ T A G >----------------------------------------------------
Module entry point from an {{#invoke:}}.
]]
Line 1,745 ⟶ 1,736:
that disambiguator must be omitted (they are not present in the data name-to-tag tables).
Module entry point from another module.
]]
Line 1,770 ⟶ 1,761:
template = table.concat ({'{{', args['template'], '}}: '}); -- make template name (if provided by the template)
end
return
end
Line 1,777 ⟶ 1,768:
--[[--------------------------< T A G _ F R O M _ N A M E >----------------------------------------------------
Module entry point from an {{#invoke:}}.
]]
Line 1,789 ⟶ 1,780:
--[[--------------------------< I S _ L A N G _ N A M E >------------------------------------------------------
Module entry point from an {{#invoke:}}.
]]
Line 1,801 ⟶ 1,792:
--[[--------------------------< _ T R A N S L >----------------------------------------------------------------
Module entry point from another module.
]]
Line 1,885 ⟶ 1,876:
--[[--------------------------< T R A N S L >------------------------------------------------------------------
Module entry point from an {{#invoke:}}.
]]
Line 1,896 ⟶ 1,887:
--[[--------------------------< C A T E G O R Y _ F R O M _ T A G >--------------------------------------------
Returns category name associated with IETF language tag if valid; error message else.
All code combinations supported by {{lang}} and the {{lang-??}} templates are supported by this function.
Module entry point from another module.
]]
Line 1,916 ⟶ 1,907:
if msg then
local template = (args_t.template and table.concat ({'{{', args_t.template, '}}: '})) or ''; -- make template name (if provided by the template)
return
end
Line 1,933 ⟶ 1,924:
--[[--------------------------< C A T E G O R Y _ F R O M _ T A G >--------------------------------------------
Module entry point from an {{#invoke:}}.
]]
|