--título=Copia archivada -> |title=Archive copy? Other languages?
TODO: make sure that citation bot doesn't improperly rename translatable templates; see $fix_it currently at https://github.com/ms609/citation-bot/blob/master/Template.php#L85
require ('strict');local _month_xlate = require ('Module:Month translator')._month_xlate;
local data = mw.loadData ('Module:CS1 translator/data');local params_main_t = data.params_main_t;local params_dates_t = data.params_dates_t;local params_misc_dates_t = data.params_misc_dates_t;local params_identifiers_t = data.params_identifiers_t;local params_language_t = data.params_language_t;
----------------------------< I N _ A R R A Y >--------------------------------------------------------------
Whether needle is in haystack
local function in_array (needle, haystack) if needle
needle then return n; end end return false;end
--
local function args_get (frame, args_t) local count = 0; for _, frame_t in ipairs do -- invoke frame first, then template frame for k, v in pairs (frame_t.args) do -- for each parameter in the
v) or (v:match ('^%s$'))) then -- skip when
return count; -- return the number of parameters in
--year= parameters that hold more than the year portion of a data (French |année=8 mars 2007 for example)are NOT transla
local function date_make (args_t, cite_args_t, params_dates_t) local date, year, month, day;
if params_dates_t.date_t then -- TODO: is there a better way to do this? for _, v in ipairs (params_dates_t.date_t) do -- loop through the date-holding parameters date = args_t[v]; -- will be nil if not set if date then break end -- if set, we're done end end if params_dates_t.year_t then for _, v in ipairs (params_dates_t.year_t) do -- loop through the year-holding parameters -- may also hold month and or day year = args_t[v]; -- will be nil if not set if year then break end -- if set, we're done end end if params_dates_t.month_t then for _, v in ipairs (params_dates_t.month_t) do -- loop through the month-holding parameters month = args_t[v]; -- will be nil if not set if month then break end -- if set, we're done end end
if params_dates_t.day_t then for _, v in ipairs (params_dates_t.day_t) do -- loop through the day-holding parameters day = args_t[v]; -- will be nil if not set if day then break end -- if set, we're done end end if date then date = _month_xlate ; -- attempt translation
elseif year then -- if 'year'; without year, any spurious 'month' and/or 'day' params meaningless; pass on as-is to cs1|2 for error handling if month then month = _month_xlate ; -- if there is a month parameter, translate its value local date_parts_t = ; local date_t = for i=1, 3 do -- done this way because members of
local keys_t = ;
for _, key in ipairs (keys_t) do -- loop through the keys_t sequence table if params_dates_t[key] then -- if there is a matching table for _, param in ipairs (params_dates_t[key]) do -- get each parameter name and args_t[param] = nil; -- unset because no longer needed end end end
if date then table.insert (cite_args_t, table.concat); -- create and save parameter-like string (without pipe) if year then table.insert (cite_args_t, table.concat); -- do the same here; year because both |date= and |year= are allowed in cs1|2 end endend
--orig-date=? can have a translatable date but can also have extraneous text ... At this writing,_month_xlate expects only a date.
local function misc_date_make (args_t, cite_args_t, in_lang) local misc_date;
for _, lang in ipairs do -- first do non-English names then, because they might be present, look for English parameter names for param, en_param in pairs (data.params_misc_dates_t[lang]) do if args_t[param] then -- if the non-English parameter has a value misc_date = _month_xlate ; -- translate the date table.insert (cite_args_t, table.concat); -- make the english parameter args_t[param] = nil; -- unset, consumed no longer needed end end endend
--series=series=
TODO: should this function be German only or does it need to allow other languages? is German the only languagethat combines multiple elements into |series=?
local function series_make (args_t, cite_args_t) local series_t = ; local params = ; for _, param in ipairs (params) do if args_t[param] then table.insert (series_t, args_t[param]); -- add to temp sequence table args_t[param] = nil; -- unset, no longer needed end end
if 0 ~= #series_t then local series = table.concat (series_t, ', '); -- concatenate whichever parameters are present table.insert (cite_args_t, table.concat); -- and make a parameter endend
--isbn= or |issn= parameter. This function applies ((accept-as-written)) markup when there is some sortof parameter equivalent to cs1|2's (now deprecated) |ignore-isbn-error=
local function isxn_make (args_t, cite_args_t, type, aliases_t, ignore_params_t, ignore_values_t) local isxn; local ignore_value; for _, v in ipairs (aliases_t) do -- loop through the aliases_t sequence table if args_t[v] then isxn = args_t[v]; end args_t[v] = nil; -- unset because no longer needed end for _, v in ipairs (ignore_params_t) do -- loop through the ignor_params_t sequence table if args_t[v] then ignore_value = args_t[v]; end args_t[v] = nil; -- unset because no longer needed end if isxn and ignore_value and (in_array (ignore_value, ignore_values_t) or ignore_values_t['*']) then --
--at= for those templates that have things like |column=. Not qualified by |page= or |pages= so that cs1|2will emit an error message when both |at= and |page(s)= present.
fix> - text string that prefixes the value in <alias>; 'col. ' for example
local function at_make (args_t, cite_args_t, aliases_t, prefix) for _, alias in ipairs (aliases_t) do if args_t[alias] then table.insert (cite_args_t, table.concat); end args_t[alias] = nil; -- unset, no longer needed endend
--chapter= from concatenation of chapter number (if present) and chapter name; chapter name else
local function chapter_make_fr (args_t, cite_args_t) local chapter = args_t['titre chapitre'] or args_t['chapitre']; if chapter and (args_t['numéro chapitre'] or args_t['numéro']) then -- when chapter numbers, concatenate number with chapter name chapter = (args_t['numéro chapitre'] or args_t['numéro']) .. ' ' .. chapter; table.insert (cite_args_t, 'chapter=' .. chapter); elseif chapter then table.insert (cite_args_t, 'chapter=' .. chapter); -- here when chapter without number end
args_t['titre chapitre'] = nil; -- unset as no longer needed args_t['chapitre'] = nil; args_t['numéro chapitre'] = nil; args_t['numéro'] = nil;end
--id=
local function id_make (frame, args_t, cite_args_t, params_identifiers_t) local id_t = ; local value;
for _, identifier_t in ipairs (params_identifiers_t) do if args_t[identifier_t[1]] then -- if this identifier parameter has a value local value_t = if identifier_t[2] then -- if there is a label (all except |id= should have a label) table.insert (value_t, identifier_t[2]); -- the label table.insert (value_t, ': '); -- the necessary punctuation and spacing if identifier_t[3] then -- if an extlink prefix table.insert (value_t, '['); -- open extlink markup table.insert (value_t, identifier_t[3]); -- the link prefix table.insert (value_t, args_t[identifier_t[1]]); -- the identifier value if identifier_t[4] then -- postfix? table.insert (value_t, identifier_t[4]); -- the link postfix end table.insert (value_t, ' '); -- require space between url and label table.insert (value_t, args_t[identifier_t[1]]); -- the identifier value as label table.insert (value_t, ']'); -- close extlink markup else table.insert (value_t, args_t[identifier_t[1]]); -- the identifier value end else table.insert (value_t, args_t[identifier_t[1]]); -- no label so value only end
table.insert (id_t, table.concat (value_t)); -- add to temp sequence table args_t[identifier_t[1]] = nil; -- unset, no longer needed end end
if 0 ~= #id_t then local id = table.concat (id_t, ', '); -- concatenate whichever parameters are present into a comma-separated list table.insert (cite_args_t, table.concat); -- and make a parameter endend
--title= with |subtitle= to make new |title=
local function title_make_fr (args_t, cite_args_t) local title = args_t['titre']; -- get the 'required' title parameter args_t['titre'] = nil; -- unset as no longer needed if not title then title = args_t['titre original'] or args_t['titre vo']; -- if |titre= empty or missing use one of these 'aliases' args_t['titre original'] = nil; -- unset as no longer needed args_t['titre vo'] = nil; end
if title then -- only when there is a title if args_t['sous-titre'] then -- add subtitle if present title = title .. ': ' .. args_t['sous-titre']; args_t['sous-titre'] = nil; -- unset as no longer needed end table.insert (cite_args_t, 'title=' .. (title or )); -- add to cite_args_t endend
--title= with |subtitle= to make new |title=
local function title_make_pt (args_t, cite_args_t) local title = args_t['título'] or args_t['titulo'] or args_t['titlo']; -- get the 'required' title parameter args_t['título'] = nil; -- unset as no longer needed args_t['titulo'] = nil; args_t['titlo'] = nil; if not title then return end
if args_t['subtítulo'] or args_t['subtitulo'] then -- add subtitle if present title = title .. ': ' .. (args_t['subtítulo'] or args_t['subtitulo']); args_t['subtítulo'] = nil; -- unset as no longer needed args_t['subtitulo'] = nil; end table.insert (cite_args_t, 'title=' .. (title or )); -- add to cite_args_tend
--dead-url= parameter aliases
local function url_status_make (args_t, cite_args_t, aliases_t, no_values_t) for _, alias in ipairs (aliases_t) do -- loop through the aliases_t sequence table if args_t[alias] and no_values_t[args_t[alias]] then -- if the alias has a value and the value equates to 'no' table.insert (cite_args_t, 'url-status=live') end args_t[alias] = nil; -- unset because no longer necessary endend
--subscription= or |registration= parameter aliases
local function url_access_make (args_t, cite_args_t, type, aliases_t, values_t) for _, alias in ipairs (aliases_t) do -- loop through the aliases_t sequence table if in_array (args_t[alias], values_t) or (args_t[alias] and values_t['*']) then -- if the alias has a value and the value equates to 'yes' or the wildcard if 'subscription'
----------------------------< L A N G U A G E _ T A G _ G E T >----------------------------------------------
Test
When
local function language_tag_get (known_langs_t, lang) if mw.language.isKnownLanguageTag (lang) then return lang; --
--language= when searches that table for this function takes no action and returns nothing when language names are expected to be properly capitalized and spelled according to the rules of the source wiki sothe match must be exact.
local function language_make (args_t, cite_args_t, in_lang, lang_params_t) local lang_param; local lang_param_val;
for _, v in ipairs (lang_params_t[in_lang]) do -- loop through the list of 'language' parameters supported at
local known_langs_t = mw.language.fetchLanguageNames (in_lang, 'all'); -- get k/v table of language names from MediaWiki for
--codling=, |in=, and |ling=; if any set, return the value.
If none of the non-enumerated parameters are set, inspect the enumeratable parameters |idioma=, |língua=, |lingua=in that order.
Collects the value from one of the non-enumerated parameters and returns that value or collects all of the valuesfrom one set of the enumeratable parameters and returns only that set of languages.
If other non-enumerated parameters have values or other enumeratable parameter sets have values, they are ignoredso that the template will emit unrecognized parameter errors for the improper mixture of parameter names.
TODO: possible to share this with pl?
local function language_make_pt (args_t, cite_args_t) local known_langs_t = mw.language.fetchLanguageNames ('pt', 'all'); -- get a table of known language names and tags for Portuguese local language; for _, lang_param in ipairs do -- non-enumerated language parameters if args_t[lang_param] then language = args_t[lang_param]; args_t[lang_param] = nil; return language_tag_get (known_langs_t, language); -- attempt to get a language tag; return tag or
else break; -- no
elseif args_t[lang_param..i] then table.insert (langs_t, args_t[lang_param..i]); args_t[lang_param..i] = nil; -- unset as no longer needed
elseif 0 ~= #langs_t then -- here when
else break; -- no
--name-list-style= parameter aliases
local function name_list_style_make (args_t, cite_args_t, aliases_t, values_t) for _, alias in ipairs (aliases_t) do -- loop through the aliases_t sequence table if args_t[alias] and (values_t[args_t[alias]] or values_t['*']) then -- if the alias has a recognized value table.insert (cite_args_t, table.concat); end args_t[alias] = nil; -- unset because no longer necessary endend
--2 template
local function render (frame, args_t, cite_args_t, params_main_t, template, language) local out_t = -- associative table for frame:expandTemplate local expand = args_t.expand; -- save content of |expand= to render a nowiki'd version of the translated template args_t.expand = nil; -- unset so we don't pass to cs1|2
for param, val in pairs (args_t) do -- for each parameter in the template if val and ('subst' ~= param) then -- when it has an assigned value; skip '|subst=subst:' (from AnomieBOT when it substs the cs1 template) local enum = param:match ('%d+'); -- get the enumerator if is enumerated; nil else local param_key = param:gsub ('%d+', '#'); -- replace enumerator with '#' if is enumerated
if params_main_t[param_key] then -- if params_main_t[<param_key>] maps to a cs1|2 template parameter local en_param = params_main_t[param_key]; if enum then en_param = en_param:gsub ('#', enum); -- replace '#' in enumerated cs1|2 parameter with enumerator from non-English parameter end table.insert (cite_args_t, table.concat); -- use the cs1|2 parameter with enumerator if present else table.insert (cite_args_t, table.concat); -- use non-English param end end end
local xlated_msg = table.concat ;
if expand then -- to see the translation as a raw template, create a nowiki'd version table.sort (cite_args_t); -- sort so that the nowiki rendering is pretty local xlation = table.concat ; -- the template string return frame:preprocess (table.concat); end
for _, arg in ipairs (cite_args_t) do -- spin through the sequence table of parameters local param, val = arg:match ('^([^=]+)=(.+)'); -- split parameter stringif nil
return table.concat ; -- render template with translated parametersend
----------------------------< D A T E S _ A N D _ L A N G U A G E >------------------------------------------
date and language parameter functions utilized for almost all translations (pl and pt support enumerated languageparameters)
local function dates_and_language (args_t, cite_args_t, in_lang) date_make (args_t, cite_args_t, params_dates_t[in_lang]); -- assemble and translate |date= misc_date_make (args_t, cite_args_t, in_lang); language_make (args_t, cite_args_t, in_lang, params_language_t); -- translate language from German to appropriate language tagend
--
--id=
return render (frame, args_t, cite_args_t, params_main_t.ar, template, 'Arabic'); -- now go render the citationend
local function cite_book_ar (frame) return _cite_ar (frame, 'cite book/subst');end
local function cite_journal_ar (frame) return _cite_ar (frame, 'cite journal/subst');end
local function cite_news_ar (frame) return _cite_ar (frame, 'cite news/subst');end
local function cite_web_ar (frame) return _cite_ar (frame, 'cite web/subst');end
--
local function _cite_ca (frame, template) local args_t = ; -- a table of k/v pairs that holds the template's parameters args_get (frame, args_t); -- get the parameters and their values local cite_args_t = ; -- a sequence table that holds parameter=value strings (without pipes); for sorting
-- special cases dates_and_language (args_t, cite_args_t, 'ca'); -- translate dates and language parameters
return render (frame, args_t, cite_args_t, params_main_t.ca, template, 'Catalon'); -- now go render the citationend
local function cite_news_ca (frame) return _cite_ca (frame, 'cite news/subst');end
local function cite_web_ca (frame) return _cite_ca (frame, 'cite web/subst');end
local function _cite_da (frame, template) local args_t = ; -- a table of k/v pairs that holds the template's parameters args_get (frame, args_t); -- get the parameters and their values local cite_args_t = ; -- a sequence table that holds parameter=value strings (without pipes); for sorting
-- special cases dates_and_language (args_t, cite_args_t, 'da'); -- translate dates and language parameters
url_status_make (args_t, cite_args_t,,);
url_access_make (args_t, cite_args_t, 'subscription',,); url_access_make (args_t, cite_args_t, 'registration',,);
isxn_make (args_t, cite_args_t, 'isbn',,,); return render (frame, args_t, cite_args_t, params_main_t.da, template, 'Danish'); -- now go render the citationend
local function cite_book_da (frame) return _cite_da (frame, 'cite book/subst');end
local function cite_journal_da (frame) return _cite_da (frame, 'cite journal/subst');end
local function cite_web_da (frame) return _cite_da (frame, 'cite web/subst');end
--
local function _cite_de (frame, template) local args_t = ; -- a table of k/v pairs that holds the template's parameters args_get (frame, args_t); -- get the parameters and their values local cite_args_t = ; -- a sequence table that holds parameter=value strings (without pipes); for sorting
-- special cases dates_and_language (args_t, cite_args_t, 'de'); -- translate dates and language parameters
series_make (args_t, cite_args_t); -- assemble |series=
local isxn;
for _, param in ipairs do -- these two parameters take a 'broken' but valid isbn if args_t[param] then isxn = table.concat ; -- create |isbn=((
)) end args_t[param] = nil; -- unset because no longer needed end if isxn then table.insert (cite_args_t, isxn); -- save the parameter end if args_t['issnformalfalsch'] then -- these parameter takes a 'broken' but valid issn isxn = table.concat ; -- create |issn=((
)) table.insert (cite_args_t, isxn); -- save the parameter end args_t['issnformalfalsch'] = nil; -- unset because no longer needed
at_make (args_t, cite_args_t,, 'col. '); -- assemble |at=col. ...
id_make (frame, args_t, cite_args_t, params_identifiers_t.de); -- assemble |id= if args_t.hrsg then if template
return render (frame, args_t, cite_args_t, params_main_t.de, template, 'German'); -- now go render the citationend
local function cite_book_de (frame) return _cite_de (frame, 'citation/subst'); -- TODO: change this to 'cite book/German'?end
local function cite_web_de (frame) return _cite_de (frame, 'cite web/subst'); -- TODO: change this to 'cite book/German'?end
--
local function _cite_es (frame, template) local args_t = ; -- a table of k/v pairs that holds the template's parameters args_get (frame, args_t); -- get the parameters and their values
local cite_args_t = ; -- a sequence table that holds parameter=value strings (without pipes); for sorting
-- special cases dates_and_language (args_t, cite_args_t, 'es'); -- translate dates and language parameters
url_status_make (args_t, cite_args_t,,); url_access_make (args_t, cite_args_t, 'subscription',,); url_access_make (args_t, cite_args_t, 'registration',,)
isxn_make (args_t, cite_args_t, 'isbn',,,); -- |ignore-isbn-error=
name_list_style_make (args_t, cite_args_t,,);
return render (frame, args_t, cite_args_t, params_main_t.es, template, 'Spanish'); -- now go render the citation
end
--
local function cite_book_es (frame) return _cite_es (frame, 'cite book/subst');end
--
local function cite_journal_es (frame) return _cite_es (frame, 'cite journal/subst');end
--
local function cite_news_es (frame) return _cite_es (frame, 'cite news/subst');end
--
local function cite_web_es (frame) return _cite_es (frame, 'cite web/subst');end
--
local function _cite_fi (frame, template) local args_t = ; -- a table of k/v pairs that holds the template's parameters args_get (frame, args_t); -- get the parameters and their values
local cite_args_t = ; -- a sequence table that holds parameter=value strings (without pipes); for sorting
-- special cases dates_and_language (args_t, cite_args_t, 'fi'); -- translate dates and language parameters
at_make (args_t, cite_args_t,, 'col. ')
return render (frame, args_t, cite_args_t, params_main_t.fi, template, 'Finish'); -- now go render the citationend
local function cite_book_fi (frame) return _cite_fi (frame, 'cite book/subst');end
local function cite_journal_fi (frame) return _cite_fi (frame, 'cite journal/subst');end
local function cite_web_fi (frame) return _cite_fi (frame, 'cite web/subst');end
--
local function _cite_fr (frame, template) local args_t = ; -- a table of k/v pairs that holds the template's parameters args_get (frame, args_t); -- get the parameters and their values
local cite_args_t = ; -- a sequence table that holds parameter=value strings (without pipes); for sorting
-- special cases dates_and_language (args_t, cite_args_t, 'fr'); -- translate dates and language parameters
if template:find ('book', 1, true) then chapter_make_fr (args_t, cite_args_t) else if args_t['numéro'] then cite_args_t.issue = args_t['numéro']; args_t['numéro'] = nil; end end
title_make_fr (args_t, cite_args_t);
if args_t['accès url'] then local values = ; -- 'libre' not supported; include it to get the error message table.insert (cite_args_t, 'url-access=' .. (values[args_t['accès url']] or args_t['accès url'])); args_t['accès url'] = nil; end
url_status_make (args_t, cite_args_t,,);
if 'oui'
args_t['et alii'] then -- accepted value 'oui'; special case |display-authors=etal table.insert (cite_args_t, 'display-authors=etal'); args_t['et al.'] = nil; -- unset as no longer needed args_t['et alii'] = nil; end if args_t['isbn erroné'] then table.insert (cite_args_t, 'isbn=((' .. args_t['isbn erroné'] .. '))'); -- apply accept-as-written markup args_t['isbn'] = nil; -- can't have |isbn= and |isbn erroné= args_t['isbn erroné'] = nil; -- unset as no longer needed end
local volume; if args_t['titre volume'] or args_t['tome'] then if args_t['tome'] then volume = args_t['tome']; -- begin with volume 'number' end if volume then volume = volume .. ' ' .. args_t['tome']; -- append volume 'title' else volume = args_t['titre volume']; -- just volume 'title' end args_t['titre volume'] = nil; -- unset as no longer needed args_t['tome'] = nil; end
id_make (frame, args_t, cite_args_t, params_identifiers_t.fr); -- assemble |id= if args_t['pages'] then args_t['pages'] = nil; -- unset; alias of |pages totales=; no equivalent in cs1|2 end
return render (frame, args_t, cite_args_t, params_main_t.fr, template, 'French'); -- now go render the citationend
local function cite_book_fr (frame) return _cite_fr (frame, 'cite book/subst');end
local function cite_journal_fr (frame) return _cite_fr (frame, 'cite journal/subst');end
local function cite_web_fr (frame) return _cite_fr (frame, 'cite web/subst');end
--
local function _cite_it (frame, template) local args_t = ; -- a table of k/v pairs that holds the template's parameters args_get (frame, args_t); -- get the parameters and their values
local cite_args_t = ; -- a sequence table that holds parameter=value strings (without pipes); for sorting
-- special cases dates_and_language (args_t, cite_args_t, 'it'); -- translate dates and language parameters
url_status_make (args_t, cite_args_t,,); url_access_make (args_t, cite_args_t, 'subscription',,); -- |richiestasottoscrizione=
isxn_make (args_t, cite_args_t, 'isbn',,,); -- |ignore-isbn-error=
name_list_style_make (args_t, cite_args_t,,); -- listed in ~/Whitelist and ~/Configuration but not supported in main module
if args_t['etal'] then -- apparently any value (typically 's', 'sì', or 'si'); rather like |display-authors=etal table.insert (cite_args_t, 'display-authors=etal'); args_t['etal'] = nil; end if args_t['etalcuratori'] then table.insert (cite_args_t, 'display-editors=etal'); args_t['etalcuratori'] = nil; end
return render (frame, args_t, cite_args_t, params_main_t.it, template, 'Italian'); -- now go render the citationend
--
local function cite_book_it (frame) return _cite_it (frame, 'cite book/subst');end
--
local function cite_journal_it (frame) return _cite_it (frame, 'cite journal/subst');end
--
local function cite_news_it (frame) return _cite_it (frame, 'cite news/subst');end
--
local function cite_web_it (frame) return _cite_it (frame, 'cite web/subst');end
local function _cite_nl (frame, template) local args_t = ; -- a table of k/v pairs that holds the template's parameters args_get (frame, args_t); -- get the parameters and their values
local cite_args_t = ; -- a sequence table that holds parameter=value strings (without pipes); for sorting
-- special cases dates_and_language (args_t, cite_args_t, 'nl'); -- translate dates and language parameters
url_status_make (args_t, cite_args_t,,); id_make (frame, args_t, cite_args_t, params_identifiers_t.nl); -- assemble |id=
return render (frame, args_t, cite_args_t, params_main_t.nl, template, 'Dutch'); -- now go render the citationend
--local function cite_book_nl (frame)-- return _cite_nl (frame, 'citation/subst');--end
local function cite_book_nl (frame) return _cite_nl (frame, 'cite book/subst');end
local function cite_journal_nl (frame) return _cite_nl (frame, 'cite journal/subst');end
local function cite_web_nl (frame) return _cite_nl (frame, 'cite web/subst');end
local function _cite_pl (frame, template) local args_t = ; -- a table of k/v pairs that holds the template's parameters args_get (frame, args_t); -- get the parameters and their values
local cite_args_t = ; -- a sequence table that holds parameter=value strings (without pipes); for sorting
-- special cases date_make (args_t, cite_args_t, params_dates_t.pl); -- assemble and translate |date= misc_date_make (args_t, cite_args_t, 'pl'); if 'tak'
local i=1; -- make a counter local language; while 1 do -- loop forever TODO: same enough as pt to combine with language_make_pt? if i
return render (frame, args_t, cite_args_t, params_main_t.pl, template, 'Polish'); -- now go render the citationend
local function citation_pl (frame) return _cite_pl (frame, 'citation/subst');end
local function cite_book_pl (frame) return _cite_pl (frame, 'cite book/subst');end
local function cite_journal_pl (frame) return _cite_pl (frame, 'cite journal/subst');end
local function cite_web_pl (frame) return _cite_pl (frame, 'cite web/subst');end
--
local function _cite_pt (frame, template) local args_t = ; -- a table of k/v pairs that holds the template's parameters args_get (frame, args_t); -- get the parameters and their values
local cite_args_t = ; -- a sequence table that holds parameter=value strings (without pipes); for sorting
-- special cases date_make (args_t, cite_args_t, params_dates_t.pt); -- assemble and translate |date= misc_date_make (args_t, cite_args_t, 'pt');
title_make_pt (args_t, cite_args_t); -- join |title= with |subtitle= to make new title
url_status_make (args_t, cite_args_t,,); local language = language_make_pt (args_t, cite_args_t); -- get string of language tags and/or unknown language names (or nil if no language parameters)
if language then table.insert (cite_args_t, 'language=' .. language); end
return render (frame, args_t, cite_args_t, params_main_t.pt, template, 'Portuguese'); -- now go render the citationend
local function cite_book_pt (frame) return _cite_pt (frame, 'citation/subst');end
local function cite_book_pt (frame) return _cite_pt (frame, 'cite book/subst');end
local function cite_journal_pt (frame) return _cite_pt (frame, 'cite journal/subst');end
local function cite_news_pt (frame) return _cite_pt (frame, 'cite news/subst');end
local function cite_web_pt (frame) return _cite_pt (frame, 'cite web/subst');end
local function _cite_sv (frame, template) local args_t = ; -- a table of k/v pairs that holds the template's parameters args_get (frame, args_t); -- get the parameters and their values
local cite_args_t = ; -- a sequence table that holds parameter=value strings (without pipes); for sorting
-- special cases dates_and_language (args_t, cite_args_t, 'sv'); -- translate dates and language parameters
name_list_style_make (args_t, cite_args_t,,); id_make (frame, args_t, cite_args_t, params_identifiers_t.sv)
return render (frame, args_t, cite_args_t, params_main_t.sv, template, 'Swedish'); -- now go render the citationend
--local function citation_sv (frame)-- return _cite_sv (frame, 'citation/subst');--end
local function cite_book_sv (frame) return _cite_sv (frame, 'cite book/subst');end
local function cite_journal_sv (frame) return _cite_sv (frame, 'cite journal/subst');end
local function cite_web_sv (frame) return _cite_sv (frame, 'cite web/subst');end
--<< C I T E B O O K F U N C T I O N S >>
--
local function cite_book_ru (frame) local args_t = ; -- a table of k/v pairs that holds the template's parameters args_get (frame, args_t); -- get the parameters and their values
local cite_args_t = ; -- a sequence table that holds parameter=value strings (without pipes); for sorting
-- special cases dates_and_language (args_t, cite_args_t, 'ru'); -- translate dates and language parameters
at_make (args_t, cite_args_t,, 'col. ')
return render (frame, args_t, cite_args_t, params_main_t.ru, 'cite book/subst', 'Russian'); -- now go render the citationend
--=
--
local function _cite_no (frame, template) local args_t = ; -- a table of k/v pairs that holds the template's parameters args_get (frame, args_t); -- get the parameters and their values local cite_args_t = ; -- a sequence table that holds parameter=value strings (without pipes); for sorting
-- special cases dates_and_language (args_t, cite_args_t, 'no'); -- translate dates and language parameters
url_status_make (args_t, cite_args_t,,); url_access_make (args_t, cite_args_t, 'subscription',,); -- for |subscription= url_access_make (args_t, cite_args_t, 'registration',,); -- for |registration=
if args_t['url-tilgang'] then -- translate value assigned to |url-access= TODO: make this into a shared function? local values = ; -- 'åpen' not supported; include it to get the error message table.insert (cite_args_t, 'url-access=' .. (values[args_t['url-tilgang']] or args_t['url-tilgang'])); args_t['url-tilgang'] = nil; end
isxn_make (args_t, cite_args_t, 'isbn',,,);
if not args_t['navnelisteformat'] then name_list_style_make (args_t, cite_args_t,,); end return render (frame, args_t, cite_args_t, params_main_t.no, template, 'Norwegian'); -- now go render the citationend
local function cite_book_no (frame) return _cite_no (frame, 'cite book/subst');end
local function cite_journal_no (frame) return _cite_no (frame, 'cite journal/subst');end
local function cite_news_no (frame) return _cite_no (frame, 'cite news/subst');end
local function cite_web_no (frame) return _cite_no (frame, 'cite web/subst');end
--
local function _cite_tr (frame, template) local args_t = ; -- a table of k/v pairs that holds the template's parameters args_get (frame, args_t); -- get the parameters and their values
local cite_args_t = ; -- a sequence table that holds parameter=value strings (without pipes); for sorting
-- special cases dates_and_language (args_t, cite_args_t, 'tr'); -- translate dates and language parameters
url_status_make (args_t, cite_args_t,,); if not (args_t['url-access'] or args_t['url-erişimi'] or args_t['URLerişimi']) then url_access_make (args_t, cite_args_t, 'subscription',,) url_access_make (args_t, cite_args_t, 'registration',,) end
isxn_make (args_t, cite_args_t, 'isbn',,,);
name_list_style_make (args_t, cite_args_t,,); -- listed in ~/Whitelist and ~/Configuration (SonYazarVe) not supported in main
return render (frame, args_t, cite_args_t, params_main_t.tr, template, 'Turkish'); -- now go render the citationend
--
local function cite_book_tr (frame) return _cite_tr (frame, 'cite book/subst');end
--
local function cite_journal_tr (frame) return _cite_tr (frame, 'cite journal/subst');end
--
local function cite_news_tr (frame) return _cite_tr (frame, 'cite news/subst');end
--
local function cite_web_tr (frame) return _cite_tr (frame, 'cite web/subst');end
--<< I N T E R M E D I A T E F U N C T I O N S >>
--title= equivalent to determine which function to call, the it.wiki positional parameters are not supported.
local function _cite_es_it (frame, funct_t, template) local f_title = frame.args['título']; -- look for Spanish |title= parameter in the frame local p_title = frame:getParent.args['título']; -- and in the parent frame if (f_title and ~= f_title) or (p_title and ~= p_title) then -- when set and not be an empty string return funct_t.es (frame); -- call the Spanish version end
f_title = frame.args['titolo']; -- look for Italian |title= parameter p_title = frame:getParent.args['titolo']; if (f_title and ~= f_title) or (p_title and ~= p_title) then -- when set and not be an empty string return funct_t.it (frame); -- call the Italian version end -- when here we don't know what we've got local args_t = ; -- a table of k/v pairs that holds the template's parameters args_get (frame, args_t); -- get the parameters and their values
return render (frame, args_t,,, template, 'unknown (Italian or Spanish)'); -- can't tell what we have so translate template name onlyend
local function cite_book_es_it (frame) return _cite_es_it (frame,, 'cite book/subst'); -- determine which language (Spanish or Italian) and then call the appropriate functionend
local function cite_news_es_it (frame) return _cite_es_it (frame,, 'cite news/subst'); -- determine which language (Spanish or Italian) and then call the appropriate functionend
local function cite_web_es_it (frame) return _cite_es_it (frame,, 'cite web/subst'); -- determine which language (Spanish or Italian) and then call the appropriate functionend
--
local function cite_web_da_no (frame) local args_t = ; -- a table of k/v pairs that holds the template's parameters args_get (frame, args_t); -- get the parameters and their values local count_da = 0; -- number of parameter that are listed in
for k, _ in pairs (args_t) do -- for each parameter in
code then -- when this is a Norwegian parameter count_no = count_no + 1; -- bump the Norwegian counter end end end end
if count_da >= count_no then -- when count of da.wiki params greater than or equal to count of no.wiki parms return cite_web_da (frame); -- assume this is a da.wiki cite web else return cite_web_no (frame); -- else assume this is a no.wiki cite web endend
return