Module:Lang: Difference between revisions
Content deleted Content added
Johnrdorazio (talk | contribs) m 1 revision imported |
sync from sandbox; |
||
Line 367:
if not in_array (table.concat ({code, '-', script}), lang_name_table.variant[variant]['prefixes']) then
return code, script, region, nil, nil, table.concat ({'unrecognized variant: ', variant, ' for code-script pair: ', code, '-', script});
end
elseif is_set (region) then -- if region set, there are some prefixes that require lang code and region (en-CA-newfound)
if not in_array (code, lang_name_table.variant[variant]['prefixes']) then -- first see if lang code is all that's required (en-oxendict though en-GB-oxendict is preferred)
if not in_array (table.concat ({code, '-', region}), lang_name_table.variant[variant]['prefixes']) then -- now try for lang code and region (en-CA-newfound)
return code, script, region, nil, nil, table.concat ({'unrecognized variant: ', variant, ' for code-region pair: ', code, '-', region});
end
end
else
Line 531 ⟶ 537:
table.insert (html, '‎'); -- make sure the browser knows that we're at the end of the rtl
end
return table.concat (html); -- put it all together and done
end
Line 560 ⟶ 565:
if language_name:find ('languages') then
-- return table.concat ({'[[Category:Articles with text from the ', language_name, ' collective]]'});
return table.concat ({'[[Category:Articles with text from ', language_name, ']]'});
end
Line 822 ⟶ 828:
--[[--------------------------< _ L A N G >
entry point for {{lang}}
Line 1,278 ⟶ 1,284:
local function _is_ietf_tag (tag) -- entry point when this module is require()d into another
local c, s, r, v, p, err; -- code, script, region, private, error message
c, s, r, v, p, err = get_ietf_parts (tag); -- disassemble tag into constituent part and validate
return ((c and not err) and true) or nil; -- return true when code portion has a value without error message; nil else
end
Line 1,290 ⟶ 1,296:
]]
local function is_ietf_tag (frame)
return _is_ietf_tag (getArgs(frame
end
Line 1,339 ⟶ 1,345:
if link then -- when |link=yes, wikilink the language name
if language_name:find ('languages') then
elseif lang_data.article_name[code] then
else
end
end
Line 1,352 ⟶ 1,358:
--[[--------------------------< N A M E _ F R O M _
Module entry point from an {{#invoke:}}
Line 1,359 ⟶ 1,365:
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
end
Line 1,379 ⟶ 1,385:
local data = mw.loadData ('Module:Lang/name to tag'); -- get the reversed data tables
local lang = args[1]:lower(); -- allow any-case for the language name (speeling must till be correct)
local tag = data.rev_lang_data[lang] or data.rev_lang_name_table[lang]; -- get the code; look first in the override then in the standard
if tag then
return tag, true;
else
msg = 'language: ' .. args[1] .. ' not found' -- language name not found, error message
Line 1,405 ⟶ 1,411:
local function tag_from_name (frame) -- entry point from an {{#invoke:Lang|tag_from_name|<language name>|link=<yes>|template=<template name>}}
return result;
end
--[[--------------------------< I S _ L A N G _ N A M E >------------------------------------------------------
Module entry point from an {{#invoke:}}
]]
local function is_lang_name (frame)
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 tag_from_name()
return result and true or nil;
end
Line 1,484 ⟶ 1,503:
local function transl (frame)
end
Line 1,497 ⟶ 1,515:
lang_xx_italic = lang_xx_italic,
is_ietf_tag = is_ietf_tag,
is_lang_name = is_lang_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
|