require('strict');
local getArgs = require ('Module:Arguments').getArgs;local unicode = require ("Module:Unicode data"); -- for is_latinlocal lang = require ('Module:Lang');
local namespace = mw.title.getCurrentTitle.namespace; -- used for categorization
local err_texts =
--
local function error_msg_make (msg, template, nocat) local out = ; local category = 'Lang and lang-xx';
table.insert (out, table.concat); table.insert (out, msg); table.insert (out, table.concat); table.insert (out, ''); if (0
namespace) and not nocat then -- categorize in article space (and template space to take care of broken usages) table.insert (out, table.concat); end
return table.concat (out);end
----------------------------< S E P A R A T O R _ G E T >----------------------------------------------------
allowed separators are comma, semicolon, virgule, or a quoted string of text
local function separator_get (sep_param_val) if not sep_param_val then return ', ' end; -- not specified, use default if ','
sep_param_val then return '; ' end; if '/'
----------------------------< P A R A M _ S E L E C T >------------------------------------------------------
Selects the appropriate enumerated parameters for
local function param_select (args_t, lang_args_t, lang_xx_args_t, swap) local enum_xx = swap and '2' or '1'; local enum = swap and '1' or '2'; lang_xx_args_t.script = args_t['script' .. enum_xx]; -- these for
----------------------------< I E T F _ T A G _ M A K E >----------------------------------------------------
make ietf tag for _lang (second rendered
local function ietf_tag_make (args_t, tag, swap) local ietf_tag_t = ; -- initialize with
return table.concat (ietf_tag_t, '-'); -- concatenate subtags with hyphen separator and doneend
-- <tag>|<text1>|<text2>|swap=yes|script2=<script>|separator=[,|;|/|<quoted string>] parameters supported by both of and templates are passed along: |cat= |nocat= parameters supported only by that are not enumerated: |label= |link= enumerated parameters: |script1= - ISO 15924 script tag for |script2= - ISO 15924 script tag for |italic1= |size1= |italic2= |size2= this function calls: Module:Lang functions _lang_xx_inherit - when non-Latin
local function _lang_x2 (args_t) local tag = args_t.tag or args_t[1]; local text1 = args_t.text1 or args_t[2]; local text2 = args_t.text2 or args_t[3]; local translation = args_t.translation or args_t[4]; local template_name = args_t.template_name or 'lang-x2'; local nocat = ('yes'
args_t.cat); -- boolean
if not (tag and text1 and text2) then return error_msg_make ('missing a required argument', template_name, nocat); end if tag:find ('-', 1, true) then return error_msg_make ('invalid language tag:
' .. tag .. '; IETF format not supported', template_name, nocat); end if not unicode.is_Latin (text1) then--error (template_name) return error_msg_make ('<' .. ((err_texts[template_name:lower] and 'text2') or 'text1') .. '> is not Latin script', template_name, nocat); end if unicode.is_Latin (text2) then return error_msg_make ('<' .. ((err_texts[template_name:lower] and 'text1') or 'text2') .. '> is Latin script', template_name, nocat); end local swap = 'yes'local ietf_tags = ietf_tag_make (args_t, tag, swap); -- for calls to -- create base-form arguments tables local lang_xx_args_t = ; -- for whichever
if swap then -- non-Latin script
table.insert (out, separator_get (args_t.separator)); -- insert the separator table.insert (out, lang._lang (lang_args_t)); -- and render the other of
return table.concat (out)end
----------------------------< L A N G _ X 2 >----------------------------------------------------------------
implements ; template entry point
local function lang_x2 (frame) local args_t = getArgs (frame); return _lang_x2 (args_t);end
----------------------------< E X P O R T E D F U N C T I O N S >------------------------------------------
return