Module:Lang/utilities: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 85:
]]
 
local function ietf_tag_make (args_t, codetag, swap)
local ietf_tag_t = {codetag}; -- initialize with <codetag>
local enum = swap and '1' or '2'; -- when <swap> is true latin <text1> is rendered second by _lang()
Line 99:
--[[--------------------------< _ L A N G _ X 2 >--------------------------------------------------------------
 
mimics {{lang|<codetag>|<text1>|<text2>}} except that <text2> is not a romanization of <text1> (which is always the
Latin-script form). Intended for languages where two scripts are 'official' or 'native and equal in status' (sh
is and sr may be candidatesa candidate for this; are there others?)
 
{{lang_x2|<codetag>|<text1>|<text2>|swap=yes|script2=<script>|separator=[,|;|/|<quoted string>]}}
 
<codetag> - (required) language codetag for both of <text1> and <text2>
<text1> - (required) Latin-script text (always)
<text2> - (required) non-Latin-script text (always)
Line 121:
enumerated parameters:
|script1= - ISO 15924 script tag for <text1> -- when <text1> renders first, these are passed to _lang_xx_...() individually
|region1= - ISO 3166 region tag for <text1> -- when <text1> renders second, these are combined with <codetag> to make an IETF tag for _lang()
|variant1= - IETF tag for <text1>
 
|script2= - ISO 15924 script tag for <text2> -- when <text2> renders first, these are passed to _lang_xx_...() individually
|region2= - ISO 3166 region tag for <text2> -- when <text2> renders second, these are combined with <codetag> to make an IETF tag for _lang()
|variant2= - IETF tag for <text2>
 
Line 145:
 
local function _lang_x2 (args_t)
iflocal nottag (args_t[1] and= args_t[2].tag andor args_t[31]) then;
local text1 = args_t.text1 or args_t[2];
local text2 = args_t.text2 or args_t[3];
if not (tag and text1 and text2) then
return error_msg_make ('missing a required argument', 'lang-x2', args_t);
end
if args_t[1]tag:find ('-', 1, true) then
return error_msg_make ('invalid language codetag: <code style="color: inherit; background: inherit; border: none; padding: inherit;">' .. args_t[1]tag .. '</code>; IETF format not supported', 'lang-x2', args_t);
end
if not unicode.is_Latin (args_t[2]text1) then
return error_msg_make ('<code style="color: inherit; background: inherit; border: none; padding: inherit;">&lt;text1></code> is not Latin script', 'lang-x2', args_t);
end
if unicode.is_Latin (args_t[3]text2) then
return error_msg_make ('<code style="color: inherit; background: inherit; border: none; padding: inherit;">&lt;text2></code> is Latin script', 'lang-x2', args_t);
end
Line 160 ⟶ 163:
local swap = 'yes' == args_t.swap; -- boolean
local out = {};
-- local code = args_t[1];
-- local text1 = args_t[2];
-- local text2 = args_t[3];
local translation = args_t[4];
 
local ietf_tags = ietf_tag_make (args_t, codetag, swap); -- for calls to {{lang}}
-- create base-form arguments tables
local lang_xx_args_t = {['code']=codetag, ['label']=args_t.label, ['link']=args_t.link, ['cat']=args_t.cat, ['nocat']=args_t.nocat}; -- for whichever <textn> renders first
local lang_args_t = {['code']=ietf_tags, ['cat']=args_t.cat, ['nocat']=args_t.nocat}; -- for whichever <textn> renders second