Module:CS1 translator and Module:CS1 translator/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
No edit summary |
Shonebrooks (talk | contribs) m I corrected the spelling of "function." WP:TYPO |
||
Line 18: | Line 18: | ||
local params_language_t = data.params_language_t; |
local params_language_t = data.params_language_t; |
||
local content_lang = mw.getContentLanguage().code; -- this wiki's language tag |
|||
--[[--------------------------< I N _ A R R A Y >-------------------------------------------------------------- |
--[[--------------------------< I N _ A R R A Y >-------------------------------------------------------------- |
||
Line 347: | Line 346: | ||
args_t['titre'] = nil; -- unset as no longer needed |
args_t['titre'] = nil; -- unset as no longer needed |
||
if not title then |
if not title then |
||
title = args_t['titre original'] or args_t['titre vo']; |
title = args_t['titre original'] or args_t['titre vo'] or args_t['titre ouvrage']; -- if |titre= empty or missing use one of these 'aliases' |
||
args_t['titre original'] = nil; -- unset as no longer needed |
args_t['titre original'] = nil; -- unset as no longer needed |
||
args_t['titre vo'] = nil; |
args_t['titre vo'] = nil; |
||
args_t['titre ouvrage'] = nil; |
|||
end |
end |
||
Line 356: | Line 356: | ||
title = title .. ': ' .. args_t['sous-titre']; |
title = title .. ': ' .. args_t['sous-titre']; |
||
args_t['sous-titre'] = nil; -- unset as no longer needed |
args_t['sous-titre'] = nil; -- unset as no longer needed |
||
end |
|||
if args_t['sous-titre ouvrage'] then -- maybe combine this with the 'if' above? |
|||
title = title .. ': ' .. args_t['sous-titre ouvrage']; |
|||
args_t['sous-titre ouvrage'] = nil; |
|||
end |
end |
||
table.insert (cite_args_t, 'title=' .. (title or '')); -- add to cite_args_t |
table.insert (cite_args_t, 'title=' .. (title or '')); -- add to cite_args_t |
||
Line 582: | Line 586: | ||
]] |
]] |
||
local function render (frame, args_t, cite_args_t, params_main_t, template |
local function render (frame, args_t, cite_args_t, params_main_t, template) |
||
local out_t = {} -- associative table for frame:expandTemplate |
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 |
local expand = args_t.expand; -- save content of |expand= to render a nowiki'd version of the translated template |
||
Line 603: | Line 607: | ||
end |
end |
||
end |
end |
||
local language = mw.language.fetchLanguageName (lang_tag, content_lang); |
|||
local xlated_msg = table.concat ({ |
|||
'<!-- auto-translated from ', |
|||
('' == language) and lang_tag or language, -- normally language but there is 'unknown (Italian or Spanish)' |
|||
' by Module:CS1 translator -->' |
|||
}); |
|||
if expand then -- to see the translation as a raw template, create a nowiki'd version |
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 |
table.sort (cite_args_t); -- sort so that the nowiki rendering is pretty |
||
local xlation = table.concat ({'{{', template, ' |', table.concat (cite_args_t, ' |'), '}}'}); -- the template string |
local xlation = table.concat ({'{{', template, ' |', table.concat (cite_args_t, ' |'), '}}'}); -- the template string |
||
xlation = frame:callParserFunction ({name='#tag', args={'nowiki', xlation}}); -- apply nowiki |
|||
return frame:preprocess (table.concat ({'<syntaxhighlight lang="wikitext" inline="1">', xlation, xlated_msg, '</syntaxhighlight>'})); |
|||
return table.concat ({'<code>', xlation, '</code>'}); -- wrap in code tags and done |
|||
end |
end |
||
Line 624: | Line 621: | ||
end |
end |
||
local xlated_msg = '<!-- auto-translated by Module:CS1 translator -->'; |
|||
return table.concat ({frame:expandTemplate ({title=template, args=out_t}), xlated_msg}); -- render {{<template>}} template with translated parameters |
return table.concat ({frame:expandTemplate ({title=template, args=out_t}), xlated_msg}); -- render {{<template>}} template with translated parameters |
||
end |
end |
||
Line 644: | Line 642: | ||
--[[=========================<< C O M B I N E D _ F U N C T I O N S >>========================================= |
--[[=========================<< C O M B I N E D _ F U N C T I O N S >>========================================= |
||
]] |
]] |
||
--[[--------------------------< _ C I T E _ A R >-------------------------------------------------------------- |
|||
Common function to implement: |
|||
{{cite book/Arabic}} (ar:قالب:استشهاد بكتاب) |
|||
{{cite journal/Arabic}} (ar:قالب:استشهاد بدورية محكمة) |
|||
{{cite news/Arabic{{ (ar:قالب:استشهاد بخبر) |
|||
{{cite web/Arabic}} (ar:قالب:استشهاد ويب) |
|||
]] |
|||
local function _cite_ar (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, 'ar'); -- translate dates and language parameters |
|||
-- url_status_make (args_t, cite_args_t, {'deadurl', 'dead-url', 'dodeurl', 'dode-url'}, {['no'] = true, ['nee'] = true}); -- no Arabic status keywords 2023-12-08 |
|||
-- id_make (frame, args_t, cite_args_t, params_identifiers_t.ar); -- assemble |id= |
|||
return render (frame, args_t, cite_args_t, params_main_t.ar, template, 'ar'); -- now go render the citation |
|||
end |
|||
--[[--------------------------< C I T E _ B O O K _ A R >------------------------------------------------------ |
|||
entry point for {{cite book/Arabic}} |
|||
]] |
|||
local function cite_book_ar (frame) |
|||
return _cite_ar (frame, 'cite book/subst'); |
|||
end |
|||
--[[--------------------------< C I T E _ J O U R N A L _ A R >------------------------------------------------ |
|||
entry point for {{cite journal/Arabic}} |
|||
]] |
|||
local function cite_journal_ar (frame) |
|||
return _cite_ar (frame, 'cite journal/subst'); |
|||
end |
|||
--[[--------------------------< C I T E _ N E W S _ A R >------------------------------------------------------ |
|||
entry point for {{cite news/Arabic}} |
|||
]] |
|||
local function cite_news_ar (frame) |
|||
return _cite_ar (frame, 'cite news/subst'); |
|||
end |
|||
--[[--------------------------< C I T E _ W E B _ A R >-------------------------------------------------------- |
|||
entry point for {{cite web/Arabic}} |
|||
]] |
|||
local function cite_web_ar (frame) |
|||
return _cite_ar (frame, 'cite web/subst'); |
|||
end |
|||
--[[--------------------------< _ C I T E _ C A >-------------------------------------------------------------- |
--[[--------------------------< _ C I T E _ C A >-------------------------------------------------------------- |
||
Common function to implement: |
Common function to implement: |
||
{{cite book/Catalan}} (ca:Plantilla:Ref-llibre) |
|||
{{cite journal/Catalan}} (ca:Plantilla:Ref-publicació) |
|||
{{cite news/Catalan}} (ca:Plantilla:Ref-notícia) |
|||
{{cite web/Catalan}} (ca:Plantilla:Ref-web) |
{{cite web/Catalan}} (ca:Plantilla:Ref-web) |
||
Line 734: | Line 657: | ||
dates_and_language (args_t, cite_args_t, 'ca'); -- translate dates and language parameters |
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 |
return render (frame, args_t, cite_args_t, params_main_t.ca, template); -- now go render the citation |
||
end |
|||
--[[--------------------------< C I T E _ B O O K _ C A >------------------------------------------------------ |
|||
entry point for {{cite book/Catalan}} |
|||
]] |
|||
local function cite_book_ca (frame) |
|||
return _cite_ca (frame, 'cite book/subst'); |
|||
end |
end |
||
Line 757: | Line 669: | ||
local function cite_news_ca (frame) |
local function cite_news_ca (frame) |
||
return _cite_ca (frame, 'cite news/subst'); |
return _cite_ca (frame, 'cite news/subst'); |
||
end |
|||
--[[--------------------------< C I T E _ J O U R N A L _ C A >------------------------------------------------ |
|||
entry point for {{cite journal/Catalan}} |
|||
]] |
|||
local function cite_journal_ca (frame) |
|||
return _cite_ca (frame, 'cite journal/subst'); |
|||
end |
end |
||
Line 806: | Line 707: | ||
isxn_make (args_t, cite_args_t, 'isbn', {'isbn', 'isbn13'}, {'ignorer-isbn-fejl', 'ignoreisbnerror', 'ignore-isbn-error'}, {'yes', 'true', 'y', 'ja', 'sand', 'j'}); |
isxn_make (args_t, cite_args_t, 'isbn', {'isbn', 'isbn13'}, {'ignorer-isbn-fejl', 'ignoreisbnerror', 'ignore-isbn-error'}, {'yes', 'true', 'y', 'ja', 'sand', 'j'}); |
||
return render (frame, args_t, cite_args_t, params_main_t.da, template |
return render (frame, args_t, cite_args_t, params_main_t.da, template); -- now go render the citation |
||
end |
end |
||
Line 897: | Line 798: | ||
end |
end |
||
return render (frame, args_t, cite_args_t, params_main_t.de, template |
return render (frame, args_t, cite_args_t, params_main_t.de, template); -- now go render the citation |
||
end |
end |
||
Line 946: | Line 847: | ||
name_list_style_make (args_t, cite_args_t, {'ampersand', 'lastauthoramp', 'last-author-amp'}, {['*']='amp'}); |
name_list_style_make (args_t, cite_args_t, {'ampersand', 'lastauthoramp', 'last-author-amp'}, {['*']='amp'}); |
||
return render (frame, args_t, cite_args_t, params_main_t.es, template |
return render (frame, args_t, cite_args_t, params_main_t.es, template); -- now go render the citation |
||
end |
end |
||
Line 1,012: | Line 913: | ||
at_make (args_t, cite_args_t, {'palsta', 'palstat'}, 'col. ') |
at_make (args_t, cite_args_t, {'palsta', 'palstat'}, 'col. ') |
||
return render (frame, args_t, cite_args_t, params_main_t.fi, template |
return render (frame, args_t, cite_args_t, params_main_t.fi, template); -- now go render the citation |
||
end |
end |
||
Line 1,093: | Line 994: | ||
args_t['isbn'] = nil; -- can't have |isbn= and |isbn erroné= |
args_t['isbn'] = nil; -- can't have |isbn= and |isbn erroné= |
||
args_t['isbn erroné'] = nil; -- unset as no longer needed |
args_t['isbn erroné'] = nil; -- unset as no longer needed |
||
end |
|||
if args_t['auteurs ouvrage'] then |
|||
table.insert (cite_args_t, 'veditors=((' .. args_t['auteurs ouvrage'] .. '))'); -- apply as-wrtn markup |
|||
args_t['auteurs ouvrage'] = nil; -- unset as no longer needed |
|||
end |
end |
||
Line 1,112: | Line 1,018: | ||
id_make (frame, args_t, cite_args_t, params_identifiers_t.fr); -- assemble |id= |
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 |
-- args_t['pages'] = nil; -- unset; alias of |pages totales=; no equivalent in cs1|2 |
||
-- end |
|||
local page = args_t['passage'] or ''; |
|||
if args_t['pages totales'] then |
|||
page = page .. ' <!--pages totales=' .. args_t['pages totales'] .. '--> '; -- append as hidden comment to page |
|||
args_t['pages totales'] = nil; -- unset as no longer needed |
|||
args_t['passage'] = nil; -- unset as no longer needed |
|||
table.insert (cite_args_t, 'page=' .. page); |
|||
end |
end |
||
return render (frame, args_t, cite_args_t, params_main_t.fr, template |
return render (frame, args_t, cite_args_t, params_main_t.fr, template); -- now go render the citation |
||
end |
end |
||
Line 1,131: | Line 1,044: | ||
--[[--------------------------< C I T E _ |
--[[--------------------------< C I T E _ C H A P T E R _ F R >------------------------------------------------------ |
||
entry point for {{cite |
entry point for {{cite chapter/French}} |
||
]] |
]] |
||
local function |
local function cite_chapter_fr (frame) |
||
return _cite_fr (frame, 'cite |
return _cite_fr (frame, 'cite book/subst'); -- similar enough to buddy up on 'book' for now, until a dedicated one is needed |
||
end |
end |
||
--[[--------------------------< C I T E _ J O U R N A L _ F R >------------------------------------------------ |
|||
entry point for {{cite journal/French}} |
|||
--[[--------------------------< C I T E _ N E W S _ F R >------------------------------------------------------ |
|||
entry point for {{cite news/French}} |
|||
]] |
]] |
||
local function |
local function cite_journal_fr (frame) |
||
return _cite_fr (frame, 'cite |
return _cite_fr (frame, 'cite journal/subst'); |
||
end |
end |
||
Line 1,195: | Line 1,107: | ||
end |
end |
||
return render (frame, args_t, cite_args_t, params_main_t.it, template |
return render (frame, args_t, cite_args_t, params_main_t.it, template); -- now go render the citation |
||
end |
end |
||
Line 1,266: | Line 1,178: | ||
return render (frame, args_t, cite_args_t, params_main_t.nl, template |
return render (frame, args_t, cite_args_t, params_main_t.nl, template); -- now go render the citation |
||
end |
end |
||
Line 1,382: | Line 1,294: | ||
end |
end |
||
return render (frame, args_t, cite_args_t, params_main_t.pl, template |
return render (frame, args_t, cite_args_t, params_main_t.pl, template); -- now go render the citation |
||
end |
end |
||
Line 1,462: | Line 1,374: | ||
end |
end |
||
return render (frame, args_t, cite_args_t, params_main_t.pt, template |
return render (frame, args_t, cite_args_t, params_main_t.pt, template); -- now go render the citation |
||
end |
end |
||
Line 1,543: | Line 1,455: | ||
id_make (frame, args_t, cite_args_t, params_identifiers_t.sv) |
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 |
return render (frame, args_t, cite_args_t, params_main_t.sv, template); -- now go render the citation |
||
end |
end |
||
Line 1,590: | Line 1,502: | ||
end |
end |
||
--[[=========================<< C I T E B O O K F U N C T I O N S >>======================================= |
|||
]] |
|||
--[[--------------------------< C I T E _ B O O K _ R U >------------------------------------------------------ |
--[[--------------------------< C I T E _ B O O K _ R U >------------------------------------------------------ |
||
Line 1,608: | Line 1,523: | ||
at_make (args_t, cite_args_t, {'столбцы'}, 'col. ') |
at_make (args_t, cite_args_t, {'столбцы'}, 'col. ') |
||
return render (frame, args_t, cite_args_t, params_main_t.ru, 'cite book/subst |
return render (frame, args_t, cite_args_t, params_main_t.ru, 'cite book/subst'); -- now go render the citation |
||
end |
end |
||
Line 1,647: | Line 1,562: | ||
end |
end |
||
return render (frame, args_t, cite_args_t, params_main_t.no, template |
return render (frame, args_t, cite_args_t, params_main_t.no, template); -- now go render the citation |
||
end |
end |
||
Line 1,699: | Line 1,614: | ||
--[[--------------------------< _ C I T E _ T R >-------------------------------------------------------------- |
--[[--------------------------< _ C I T E _ T R >-------------------------------------------------------------- |
||
implements {{Web kaynağı}} (:tr:Şablon:Web_kaynağı, :tr:Şablon:Akademik dergi kaynağı (journal)) |
|||
implements: |
|||
{{Akademik dergi kaynağı}} (:tr:Şablon:Akademik dergi kaynağı) – {{cite journal}} |
|||
{{Haber kaynağı}} (:tr:Şablon:Haber kaynağı) – {{cite news}} |
|||
{{Kitap kaynağı}} (:tr:Şablon:Kitap kaynağı) – {{cite book}} |
|||
{{Web kaynağı}} (:tr:Şablon:Web_kaynağı) – {{cite web}} |
|||
]] |
]] |
||
Line 1,726: | Line 1,637: | ||
name_list_style_make (args_t, cite_args_t, {'last-author-amp', 'lastauthoramp', 'sonyazarve'}, {['*']='amp'}); -- listed in ~/Whitelist and ~/Configuration (SonYazarVe) not supported in main |
name_list_style_make (args_t, cite_args_t, {'last-author-amp', 'lastauthoramp', 'sonyazarve'}, {['*']='amp'}); -- listed in ~/Whitelist and ~/Configuration (SonYazarVe) not supported in main |
||
return render (frame, args_t, cite_args_t, params_main_t.tr, template |
return render (frame, args_t, cite_args_t, params_main_t.tr, template); -- now go render the citation |
||
end |
end |
||
Line 1,732: | Line 1,643: | ||
--[[--------------------------< C I T E _ B O O K _ T R >------------------------------------------------------ |
--[[--------------------------< C I T E _ B O O K _ T R >------------------------------------------------------ |
||
implements {{ |
implements {{Web kaynağı}} (:tr:Şablon:Web_kaynağı) |
||
]] |
]] |
||
Line 1,749: | Line 1,660: | ||
local function cite_journal_tr (frame) |
local function cite_journal_tr (frame) |
||
return _cite_tr (frame, 'cite journal/subst'); |
return _cite_tr (frame, 'cite journal/subst'); |
||
end |
|||
--[[--------------------------< C I T E _ N E W S _ T R >------------------------------------------------------ |
|||
implements {{Haber kaynağı}} (:tr:Şablon:Haber kaynağı) |
|||
]] |
|||
local function cite_news_tr (frame) |
|||
return _cite_tr (frame, 'cite news/subst'); |
|||
end |
end |
||
Line 1,792: | Line 1,692: | ||
]] |
]] |
||
local function _cite_es_it (frame, funct_t |
local function _cite_es_it (frame, funct_t) |
||
local f_title = frame.args['título']; -- look for Spanish |title= parameter in the frame |
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 |
local p_title = frame:getParent().args['título']; -- and in the parent frame |
||
Line 1,806: | Line 1,706: | ||
return funct_t.it (frame); -- call the Italian version |
return funct_t.it (frame); -- call the Italian version |
||
end |
end |
||
-- when here |
-- when here return an error message |
||
return '<span style="color:#d33">{{cita book/news/web}} requires |título= (Spanish) or |titolo= (Italian)</span>'; |
|||
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 only |
|||
end |
end |
||
Line 1,822: | Line 1,719: | ||
local function cite_book_es_it (frame) |
local function cite_book_es_it (frame) |
||
return _cite_es_it (frame, {es = cite_book_es, it = cite_book_it} |
return _cite_es_it (frame, {es = cite_book_es, it = cite_book_it}); -- determine which language (Spanish or Italian) and then call the appropriate function |
||
end |
end |
||
Line 1,834: | Line 1,731: | ||
local function cite_news_es_it (frame) |
local function cite_news_es_it (frame) |
||
return _cite_es_it (frame, {es = cite_news_es, it = cite_news_it} |
return _cite_es_it (frame, {es = cite_news_es, it = cite_news_it}); -- determine which language (Spanish or Italian) and then call the appropriate function |
||
end |
end |
||
Line 1,846: | Line 1,743: | ||
local function cite_web_es_it (frame) |
local function cite_web_es_it (frame) |
||
return _cite_es_it (frame, {es = cite_web_es, it = cite_web_it} |
return _cite_es_it (frame, {es = cite_web_es, it = cite_web_it}); -- determine which language (Spanish or Italian) and then call the appropriate function |
||
end |
end |
||
Line 1,883: | Line 1,780: | ||
return cite_web_no (frame); -- else assume this is a no.wiki cite web |
return cite_web_no (frame); -- else assume this is a no.wiki cite web |
||
end |
end |
||
end |
|||
--[[--------------------------< P A R A M _ N A M E S _ G E T >------------------------------------------------ |
|||
utility function to support the creation of translation data for Module:CS1 translate/data from a non-English |
|||
wikitext template. This function fetches the unparsed content of a local copy of the non-English template and |
|||
extracts a list of the parameters that it supports. |
|||
parameters: |
|||
{{{1}}} – when provided is the page name (including namespace) of the page that holds the local copy of the |
|||
non-English template; if omitted uses the current page (page with the {{#invoke}}). If a page name is not |
|||
specified, the parameter must be present if {{{2}}} is specified. |
|||
{{{2}}} – language tag of the wiki from which the non-English template was copied; 'ca' in https://ca.wikipedia.org/ |
|||
This function uses that tag to know if a certain parameter has already been translated |
|||
examples: |
|||
{{#invoke:CS1 translator|param_names_get|<page name>|<tag>}} |
|||
– non-English template is located at <page name>; <tag> specifies the template's language |
|||
{{#invoke:CS1 translator|param_names_get||<tag>}} |
|||
– non-English template is colocated with the {{#invoke}} of this function; <tag> specifies the template's language note empty {{{1}}} |
|||
return a table in lua format listing all parameter names that do not have translations. In this list, enumerated |
|||
parameter names are collapsed: 'autor1' .. 'autor4' all collapsed to 'autor#' |
|||
]] |
|||
local function param_names_get (frame) |
|||
local args_t = require ('Module:Arguments').getArgs (frame); |
|||
local template_content; -- unparsed template content goes here |
|||
local title_object |
|||
if args_t[1] then |
|||
template_content = mw.title.new(args_t[1]):getContent() or ''; -- if a page name supplied in {{{1}}} get its content |
|||
else |
|||
template_content = mw.title.getCurrentTitle():getContent() or ''; -- get the content of the current page |
|||
end |
|||
local raw_params_t = {}; -- table to hold all unique <param> names from any {{{<param name> that we find |
|||
local raw_param_count = 0; -- tally of unique raw parameters; used in final output |
|||
local params_t = {}; -- table to hold all (possibly modified) <param> names |
|||
local param_count = 0; -- tally of (possibly modified) <param> names in the template |
|||
for param in template_content:gmatch ('{{{([^|}]+)') do -- loop through <template_content> and extract parameter names |
|||
if not raw_params_t[param] then -- have we seen this parameter name? |
|||
raw_params_t[param] = true -- no; save it |
|||
raw_param_count = raw_param_count + 1; -- and tally |
|||
end |
|||
param = param:gsub ('%d+', '#'); -- replace any enumerator with '#' |
|||
if not params_t[param] then -- have we seen this (possibly modified) parameter name? |
|||
params_t[param] = true; -- no; save it |
|||
param_count = param_count + 1; -- and tally |
|||
end |
|||
end |
|||
--mw.logObject (raw_params_t) |
|||
local out_t = {}; -- sequence table to hold param names for output |
|||
local xlated_params_t = {}; -- will hold list of args_t[2] language parameter translations |
|||
if args_t[2] then -- if a language tag supplied |
|||
xlated_params_t = data.params_main_t[args_t[2]]; -- attempt to load a table of that language's parameters known to CS1 translator |
|||
end |
|||
local cs1_common_parameters_t = mw.loadData ('Module:Citation/CS1/Whitelist').common_parameters_t; -- fetch the list of cs1|2 common parameters |
|||
for param, _ in pairs (params_t) do -- loop through the list of unique template parameter names |
|||
if xlated_params_t and not xlated_params_t[param] then -- does Module:CS1 translator/data has translation data for args_t[2] language but not for this <param>? |
|||
if not cs1_common_parameters_t[param] then -- is <param> a known cs1|2 parameter? |
|||
table.insert (out_t, '[\'' .. param .. '\']'); -- no translation and not known to cs1|2, add to output list as lua table index |
|||
end |
|||
elseif not xlated_params_t then -- if no data for the args_t[2] language |
|||
table.insert (out_t, param); -- add to output list |
|||
end |
|||
end |
|||
table.sort (out_t); -- sort list of parameter names |
|||
local untranslated_count = #out_t; -- get the tally of parameter names that don't have translations |
|||
out_t = {table.concat (out_t, ' = \'\',\n\t\t')}; -- replace individual entries with a single formatted string |
|||
table.insert (out_t, 1, table.concat ({ -- open lua table and formatting |
|||
'<syntaxhighlight lang="lua">\t', |
|||
args_t[2] and args_t[2] or '??', -- language tag or '??' if not specified in {{{2}}} |
|||
'= {\n\t\t' |
|||
})); |
|||
table.insert (out_t, ' = \'\',\n\t\t}</syntaxhighlight>'); -- close lua table and formatting |
|||
table.insert (out_t, 1, table.concat ({ -- insert commentary |
|||
mw.language.fetchLanguageName (args_t[2] and args_t[2] or 'und', 'en'), -- get language name for {{{2}}} |
|||
': the template has ', |
|||
raw_param_count, -- total number of unmodified unique parameter names |
|||
' parameter names; ', |
|||
untranslated_count, -- total number of parameter names without translation |
|||
' parameter names not translated.' |
|||
})); |
|||
return frame:preprocess (table.concat (out_t)); -- and make all pretty-like and done |
|||
end |
end |
||
Line 1,993: | Line 1,787: | ||
return { |
return { |
||
param_names_get = param_names_get, -- utility function reads parameter names from wikitext template to aid creation of table in ~/data |
|||
citation_pl = citation_pl, -- pl:Szablon:Cytuj |
citation_pl = citation_pl, -- pl:Szablon:Cytuj |
||
cite_book_ar = cite_book_ar, -- ar:قالب:استشهاد بكتاب |
|||
cite_book_ca = cite_book_ca, -- ca:Plantilla:Ref-llibre |
|||
cite_book_da = cite_book_da, -- da:Skabelon:Kilde bog |
cite_book_da = cite_book_da, -- da:Skabelon:Kilde bog |
||
cite_book_de = cite_book_de, -- de:Vorlage:Literatur |
cite_book_de = cite_book_de, -- de:Vorlage:Literatur |
||
Line 2,009: | Line 1,799: | ||
cite_book_pl = cite_book_pl, -- pl:Szablon:Cytuj książkę |
cite_book_pl = cite_book_pl, -- pl:Szablon:Cytuj książkę |
||
cite_book_pt = cite_book_pt, -- pt:Predefinição:citar livro |
cite_book_pt = cite_book_pt, -- pt:Predefinição:citar livro |
||
cite_book_ru = cite_book_ru, -- ru:Шаблон:Книга |
|||
cite_book_sv = cite_book_sv, -- sv:Mall:Bokref |
cite_book_sv = cite_book_sv, -- sv:Mall:Bokref |
||
cite_book_tr = cite_book_tr, -- tr:Şablon: |
cite_book_tr = cite_book_tr, -- tr:Şablon: |
||
cite_chapter_fr = cite_chapter_fr, -- fr:Modèle:Chapitre |
|||
cite_journal_ar = cite_journal_ar, -- ar:قالب:استشهاد بدورية محكمة |
|||
cite_journal_ca = cite_journal_ca, -- ca:Plantilla:Ref-publicació |
|||
cite_journal_da = cite_journal_da, -- da:Skabelon:Kilde tidsskrift / da:Skabelon:Kilde artikel (da.wiki prefers da:Skabelon:cite journal) |
cite_journal_da = cite_journal_da, -- da:Skabelon:Kilde tidsskrift / da:Skabelon:Kilde artikel (da.wiki prefers da:Skabelon:cite journal) |
||
cite_journal_es = cite_journal_es, -- es:Plantilla:Cita publicación |
cite_journal_es = cite_journal_es, -- es:Plantilla:Cita publicación |
||
Line 2,027: | Line 1,816: | ||
cite_journal_tr = cite_journal_tr, -- tr:Şablon:Akademik dergi kaynağı |
cite_journal_tr = cite_journal_tr, -- tr:Şablon:Akademik dergi kaynağı |
||
cite_news_ca = cite_news_ca, -- ca:Plantilla:Ref-publicació |
|||
cite_news_ca = cite_news_ca, -- ca:Plantilla:Ref-notícia |
|||
cite_news_es = cite_news_es, -- en:Template:Cite news/Spanish; for cita news see cite_news_es_it() |
cite_news_es = cite_news_es, -- en:Template:Cite news/Spanish; for cita news see cite_news_es_it() |
||
cite_news_fr = cite_news_fr, -- fr:Modèle:Article |
|||
cite_news_it = cite_news_it, -- en:Template:Cite news/Italian; for cita news see cite_news_es_it() |
cite_news_it = cite_news_it, -- en:Template:Cite news/Italian; for cita news see cite_news_es_it() |
||
cite_news_no = cite_news_no, -- no:Mal:Kilde avis |
cite_news_no = cite_news_no, -- no:Mal:Kilde avis |
||
cite_news_pt = cite_news_pt, -- pt:Predefinição:citar jornal |
cite_news_pt = cite_news_pt, -- pt:Predefinição:citar jornal |
||
cite_news_tr = cite_news_tr, -- tr:Şablon:Haber kaynağı |
|||
cite_web_ar = cite_web_ar, -- ar:قالب:استشهاد ويب |
|||
cite_web_ca = cite_web_ca, -- ca:Plantilla:Ref-web |
cite_web_ca = cite_web_ca, -- ca:Plantilla:Ref-web |
||
cite_web_da = cite_web_da, -- da:Skabelon:Kilde www or da:Skabelon:Cite web |
cite_web_da = cite_web_da, -- da:Skabelon:Kilde www or da:Skabelon:Cite web |
||
Line 2,049: | Line 1,834: | ||
cite_web_pt = cite_web_pt, -- pt:Predefinição:citar web |
cite_web_pt = cite_web_pt, -- pt:Predefinição:citar web |
||
cite_web_sv = cite_web_sv, -- sv:Mall:Webbref |
cite_web_sv = cite_web_sv, -- sv:Mall:Webbref |
||
cite_web_tr = cite_web_tr, |
cite_web_tr = cite_web_tr, |
||
cite_book_es_it = cite_book_es_it, -- common entry point for {{cita book}} (Spanish es:Plantilla:Cita libro / Italian it:Template:Cita libro) |
cite_book_es_it = cite_book_es_it, -- common entry point for {{cita book}} (Spanish es:Plantilla:Cita libro / Italian it:Template:Cita libro) |