モジュール:Multilingual Arguments
- This module is used to generate a header box for Author pages in french Wikisource, replacing Modèle:Auteur. First in french, then in other languages.
- It uses Module:Multilingual_Arguments and Module:Unitest_Scribunto
- See also Module:Author and Module:Auteur and Module talk:Auteur
目次
Module:Multilingual Arguments - Argts_autotest
{{Auteur | 1 = | 2 = | 3 = | 4 = | anneeNaissance = | ARCorg = | c = | ISFDBpub = | XXX = | siecleNaissance = | genre = | ISFDBid = | incertitudeDeces = | image = | droits = | ARCid = | VIAF = | anneeNaissance = | anneeDeces = | ISFDBtitle = | GKD = | SWD = | options = fr docavant | SUDOC = | nomfamille = | wikipedia = | prénomGall = | ARCsub = | OCLC = | PND = | titre = | sexe = | BNF = | anneeDeces = | SELIBR = | LT = | prénom = | metier = | IBLbook = | IBL = | catspace = | ISFDB = | IBLid = | initiale = | commonscat = | ISBN = | incertitudeNaissance = | Category = | ARCitem = | ARC = | ARCHIVE = | IA = | GKD_V1 = | prix = | espace = | pays = | commons = | LCCN = | langue = | wikiquote = | description = | WORLDCATID = | siecleNaissance = | pseudo = | OL = | ULAN = | nom = | cle = }}
Module:Multilingual Arguments - generDoc
Lua エラー 1021 行目: attempt to index upvalue 'args_trad' (a nil value)
Module:Multilingual Arguments - multi_args
Module:Author
Lua エラー モジュール:Author 内、958 行目: attempt to call field 'erreur_lister' (a nil value)
-- This module manage arguments of a template or a module
-- it is called by templates {{Author... or {{Auteur...
-- http://www.mediawiki.org/wiki/Module:Multilingual_Arguments
--[[
-- MediaWiki 1.21wmf9 (070f4b4). 14/02/13
-- MediaWiki 1.21wmf9 (afbf386). 15/02/13 test2
-- MediaWiki 1.21wmf9 (afbf386). 15/02/13 test2
-- MediaWiki 1.21wmf10 (edeb4e1) 18/02/13 test2
-- https://gerrit.wikimedia.org/r/#/c/49601/
-- Patch Set 1 - 96615c97b03bbfacb27e749a1d42971429d76852 (gitweb)
3.25 Scribunto
6 days ago Brad JorschMake our loader work like Lua's built-in loaders 15-6=9/2/13
git #5584810 - Make our loader work like Lua's built-in loaders
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/Scribunto.git;a=commit;h=5584810c2d69602b33297821dd7467742722980f
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/Scribunto.git;a=commit;h=fddf05c0566aca35bc10b0b8fa4abed8668b7134
git #8d02895 - Create wmf/1.21wmf9 branch and update .gitreview
2013-01-31 Brad JorschLua library support functions
git #4c69b13 - Lua library support functions
git #0a8a07d - Fix package.loaded and other cleanups
editing code UTF-16 (MacRoman ?)
Exemple tous paramètres :
{{Auteur |c=:|options=fr test params
|nom=Hugo|prénom=Victor|prénomGall= Arthur
|cle=Hugo Victor|initiale=H
|image=Victor Hugo.jpg |description=écrivain français
|texte=vie |categorie=Auteurs |lien=du |liaison=de l'
|texteNaissance=a |categorieNaissance=Auteurs
|incertitudeNaissance= vers |lienNaissance=du |liaisonNaissance=en
|anneeNaissance= 1802 |siecleNaissance= 19
|texteDeces=a |categorieDeces=Auteurs
|incertitudeDeces= après |lienDeces= du |liaisonDeces=en
|anneeDeces= 1885 |siecleDeces= 19
|droits=non |pseudo=Monsieur Legrand
|genre=Romanciers/Poètes/Auteurs de théatre
|langue=français |pays=France/Italie/Grèce
|metier=Académiciens/Personnalités politiqp.md_dataues
|prix=Prix Nobel de littérature
|VIAF=34452139|NLA=35096649|BNF=cb11888266r|SELIBR=34648|PND=11850133X|LCCN=n/50/23101
|border=0
}}
-- local mw = require "Module:mw"
-- local MultiArgs = require "Module:Multilingual_Arguments"
--]]
local table_iterator = function(t) -- iterator to use all elements of a table, one by one
-- for noticeN in table_iterator(notices_properties) do
-- modele : function list_iter (t)
if type(t) ~= "table" then return { }, 0 ,0 end
local i = 0
local n = table.getn(t)
return function ()
i = i + 1
n = table.getn(t)
if t[i] ~= nil then return t[i], i ,n end
end
end
local local_erreurs = { } -- collecte de toutes les erreurs
local erreur_add = function(wt_ref, v1, v2, v3, v4, v5)
-- erreur_add("err_value_re_defined", k, key, xyz) -- pick wt_ref, replace _XnX_ by vN, keep error text
if type(wt_ref) ~= "string" then return "" end
-- if args_trad == nil then args_trad = Trad[arg_lang] end -- translation of template identifier and texts end
local wt = args_trad[wt_ref]
wt = tostring(wt)
if v1 ~= nil then wt = string.gsub(wt, "_X1X_", tostring(v1) ) end
if v2 ~= nil then wt = string.gsub(wt, "_X2X_", tostring(v2) ) end
if v3 ~= nil then wt = string.gsub(wt, "_X3X_", tostring(v3) ) end
if v4 ~= nil then wt = string.gsub(wt, "_X4X_", tostring(v4) ) end
if v4 ~= nil then wt = string.gsub(wt, "_X5X_", tostring(v5) ) end
table.insert(local_erreurs, wt)
return wt
end
local erreur_lister = function(titre)
local erreurs_wt = ""
if type(titre) ~= "string" then
titre = args_trad["err_error_list_head"]
end
for i, err in pairs(local_erreurs) do -- Pour tous les parametres connus
if err ~= "nil" then
erreurs_wt = erreurs_wt .. '⦁ ' .. erreur_color(err) .. '<br/>'
end
end
if erreurs_wt == "" then return "" end
if type(titre) == "string" then erreurs_wt = '<br/>' .. titre .. '<br/>' .. erreurs_wt end
return erreurs_wt
end
-----------------------------
-- Trad object table start
-----------------------------
local Trad = { } -- Traductions des textes locaux, sur le modèle de ProofreadPage.i18n.php $messages = array();
Trad['qqq'] = {
-- qqq is a description of each text or peculiarities.
-- qqq es una descripción de cada texto o peculiaridades.
-- qqq est une description de chaque texte, ou de ses particularités.
-- Arguments from frame:getParent()
c = 'c',
options = 'options',
lastname = 'lastname',
initiale = 'initiale',
familyname = 'familyname',
firstname = 'firstname',
pseudonym = 'pseudonym',
title = 'title',
Galliname = 'lastname',
sex = 'sex',
sortkey = 'sortkey',
image = 'image',
birthyear = 'birthyear',
birth = 'birth',
birthcentury = 'birthcentury',
birthuncertain = 'birthuncertain',
deathyear = 'deathyear',
death = 'death',
deathcentury = 'deathcentury',
deathuncertain = 'deathuncertain',
description = 'description',
occupation = 'occupation',
genre = 'genre',
language = 'language',
country = 'country',
prize = 'prize',
rights = 'rights',
wikipedia = 'wikipedia',
wikiquote = 'wikiquote',
commons = 'commons',
commonscat = 'commonscat',
namespace = 'space',
category = 'category',
catspace = 'catspace',
-- Scans and Notices
author_Scans = 'Scans qqq',
author_Notices = 'Notices qqq',
author_cat_birth_year = 'Notices qqq',
author_cat_birth_secular = 'Notices qqq',
author_cat_birth_epoch = 'Notices qqq',
-- Error messages
err_internal_argument_unknown = ' Internal error : the internal argument _X1X_ is unknown in args_import_all. Report the error to improve the model.',
err_value_re_defined = ' Error : the value of the argument _X1X_ is already defined. Choose only one argument and value.',
err_value_missing = " Error : This argument is required but absent : _X1X_. Should define it.",
err_none_value = " Erreur : Error : No argument has been defined.",
err_internal_notice_wsid = "Internal error: the internal argument <b>_X1X_</b> is unknown in the records.",
}
-- Trad['en'] = {
-- This repair a Lua bug : Trad[arg_lang]["options"] = value give an error
Trad.en = {
-- Arguments from frame:getParent()
c = 'c',
options = 'options',
lastname = 'lastname',
initiale = 'initiale',
familyname = 'familyname',
firstname = 'firstname',
pseudonym = 'pseudonym',
title = 'title',
Galliname = 'lastname',
sex = 'sex',
sortkey = 'sortkey',
image = 'image',
birthyear = 'birthyear',
birth = 'birth',
birthcentury = 'birthcentury',
birthuncertain = 'birthuncertain',
deathyear = 'deathyear',
death = 'death',
deathcentury = 'deathcentury',
deathuncertain = 'deathuncertain',
description = 'description',
occupation = 'occupation',
genre = 'genre',
language = 'language',
country = 'country',
prize = 'prize',
rights = 'rights',
wikipedia = 'wikipedia',
wikiquote = 'wikiquote',
commons = 'commons',
commonscat = 'commonscat',
namespace = 'space',
category = 'Category',
catspace = 'catspace',
-- Scans and Notices
author_Scans = 'Scans in',
author_Notices = 'Notices',
author_cat_birth_year = 'Birth in _year_',
author_cat_birth_secular = 'Birth in _secular_ secular',
author_cat_birth_epoch = 'Birth in _epoch_',
-- Error messages
err_error_list_head = "Error while displaying this template :",
err_internal_argument_unknown = 'Error: parameter "<b>_X1X_</b>" is unknown in this template. Check the name or flag this gap.',
err_value_re_defined = "Error : the value of the argument <b>_X1X_</b> is already defined. Choose only one argument and value.",
err_value_missing = "Error : This argument is required but absent : <b>_X1X_</b>. Should define it.",
err_none_value = "Erreur : Error : No argument has been defined.",
err_internal_notice_wsid = "Internal Error: Report that the internal argument <b>_X1X_</b> is unknown in the records.",
}
-- Trad['es'] = {
-- This repair a Lua bug : Trad[arg_lang]["options"] = value give an error
Trad.es = {
-- Arguments from frame:getParent()
c = 'c',
options = 'options',
lastname = 'nombre',
initiale = 'initiale',
familyname = 'primernombre',
firstname = 'apellido',
pseudonym = 'apodo',
title = 'título',
Galliname = 'apellidoGalli',
sex = 'sexo',
sortkey = 'especie clave',
image = 'imagen',
birthyear = 'año de nacimiento',
birth = 'nacimiento',
birthcentury = 'siglo de nacimiento',
birthuncertain = 'nacimiento incierto',
deathyear = 'año de la muerte',
death = 'muerte',
deathcentury = 'siglo de la muerte',
deathuncertain = 'muerte incierto',
description = 'descripción',
occupation = 'profesión',
genre = 'tipo',
language = 'lengua',
country = 'país',
prize = 'premio',
rights = 'derechos',
wikipedia = 'wikipedia',
wikiquote = 'wikiquote',
commons = 'commons',
commonscat = 'commonscat',
namespace = 'espacio',
category = 'Categoría',
catspace = 'catespacio',
-- Scans and Notices
author_Scans = 'Escanea en',
author_Notices = 'Avisos',
author_cat_birth_year = 'Naissance en _year_',
author_cat_birth_secular = 'Naissance au _secular_ siècle',
author_cat_birth_epoch = 'Birth in _epoch_',
-- Los mensajes de error
err_error_list_head = "Error mientras se muestra este modelo :",
err_internal_argument_unknown = 'Error: El parámetro "<b>_X1X_</b>" es desconocido en este modelo. Compruebe el nombre o marca esta brecha.',
err_value_re_defined = "Error : el valor del argumento <b>_X1X_</b> ya se ha definido. Elige uno sólo argumento y valor.",
err_value_missing = "Error : Este argumento es necesario pero ausente : <b>_X1X_</b>. Debe definir.",
err_none_value = "Error : Ningún argumento ha sido definido.",
err_internal_notice_wsid = "Error interno: Informe que el argumento interno <b>_X1X_</b> es desconocida en los registros.",
}
-- Trad['fr'] = {
-- This repair a Lua bug : Trad[arg_lang]["options"] = value give an error
Trad.fr = {
-- Arguments from frame:getParent()
c = 'c',
options = 'options',
lastname = 'nom',
initiale = 'initiale',
familyname = 'nomfamille',
firstname = 'prénom',
pseudonym = 'pseudo',
title = 'titre',
Galliname = 'prénomGall',
sex = 'sexe',
sortkey = 'cle',
image = 'image',
birthyear = 'anneeNaissance',
birth = 'naissance',
birthcentury = 'siecleNaissance',
birthuncertain = 'incertitudeNaissance',
deathyear = 'anneeDeces',
death = 'deces',
deathcentury = 'siecleNaissance',
deathuncertain = 'incertitudeDeces',
description = 'description',
occupation = 'metier',
genre = 'genre',
language = 'langue',
country = 'pays',
prize = 'prix',
rights = 'droits',
wikipedia = 'wikipedia',
wikiquote = 'wikiquote',
commons = 'commons',
commonscat = 'commonscat',
namespace = 'espace',
category = 'Category',
catspace = 'catspace',
-- Scans and Notices
author_Scans = 'Scans sur',
author_Notices = 'Notices',
author_cat_birth_year = 'Naissance en _year_',
author_cat_birth_secular = 'Naissance au _secular_ siècle',
author_cat_birth_epoch = 'Birth in _epoch_',
-- Messages d'erreur
err_error_list_head = 'Erreurs ou remarques sur les paramètres de ce modèle :',
err_internal_argument_unknown = 'Erreur : ce paramètre "<b>_X1X_</b>" est inconnu dans ce modèle. Vérifier ce nom ou signaler ce manque.',
err_value_re_defined = "Erreur : la valeur de l'argument <b>_X1X_</b> est déjà définie. Choisir un seul argument et une seule valeur.",
err_value_missing = "Erreur : Cet argument est nécessaire mais absent : <b>_X1X_</b>. Il faut le définir.",
err_none_value = "Erreur : Aucun argument n'a été défini.",
err_internal_notice_wsid = "Erreur interne : Signalez que l'argument interne <b>_X1X_</b> est inconnu dans les notices.",
} -- Trad
-----------------------------
-- Trad object table end
-----------------------------
local arg_lang = "fr" -- {{CONTENTLANG}} -- = ":" to display a category to document it rather than truly categorize
-- Trad[arg_lang] = { }
-- Trad[arg_lang]["options"] = " "
local args_trad = { } -- Trad[arg_lang] -- translation of template identifier and texts
if arg_lang == "en" then args_trad = Trad_en end
if arg_lang == "es" then args_trad = Trad_es end
if arg_lang == "fr" then args_trad = Trad_fr end
local args_val = nil -- direct acces to values of arguments and parameters linked
local args_source = nil -- arguments sources au niveau du module
function Trad.txt(key) -- give the translation of indentified texts, or arguments indentifier, or errors messages
local t = args_trad[key]
if t == nil then t="" end
return t
end
function Trad.init_lang(_lang)
-- if Trad.init_lang(_lang) == _lang then OK
-- en : init or change the language and its table
-- es : inicializar o cambiar el idioma y su mesa
-- fr : initialiser ou modifier la langue et sa table
local args_table = nil
-- Verify _lang, else use CONTENTLANG
if type(_lang) ~= "string" then
_lang = {{CONTENTLANG}}
end
if _lang == "" then
_lang = {{CONTENTLANG}}
end
-- args_table = Trad[_lang]
-- This repair a Lua bug : Trad[arg_lang]["options"] = value give an error
if _lang == "en" then args_table = Trad.en end
if _lang == "es" then args_table = Trad.es end
if _lang == "fr" then args_table = Trad.fr end
if type(args_table) == "table" then
-- Change language only if coherent with a table
arg_lang = _lang
args_trad = args_table
return arg_lang
else
return nil
end
end -- function Trad.init_lang(_lang)
-----------------------------
-- Trad object end
-----------------------------
local local_erreurs = { } -- collecte de toutes les erreurs
local erreur_color = function(t)
return '<span style="color:red;" >' .. tostring(t) .. '</span>'
end
local erreur_add = function(wt_ref, v1, v2, v3, v4, v5)
-- erreur_add("err_value_re_defined", k, key, xyz) -- pick wt_ref, replace _XnX_ by vN, keep error text
if type(wt_ref) ~= "string" then return "" end
-- if args_trad == nil then args_trad = Trad[arg_lang] end -- translation of template identifier and texts end
local wt = args_trad[wt_ref]
wt = tostring(wt)
if v1 ~= nil then wt = string.gsub(wt, "_X1X_", tostring(v1) ) end
if v2 ~= nil then wt = string.gsub(wt, "_X2X_", tostring(v2) ) end
if v3 ~= nil then wt = string.gsub(wt, "_X3X_", tostring(v3) ) end
if v4 ~= nil then wt = string.gsub(wt, "_X4X_", tostring(v4) ) end
if v4 ~= nil then wt = string.gsub(wt, "_X5X_", tostring(v5) ) end
table.insert(local_erreurs, wt)
return wt
end
local erreur_lister = function(titre)
local erreurs_wt = ""
if type(titre) ~= "string" then
titre = args_trad["err_error_list_head"]
end
for i, err in pairs(local_erreurs) do -- Pour tous les parametres connus
if err ~= "nil" then
erreurs_wt = erreurs_wt .. '⦁ ' .. erreur_color(err) .. '<br/>'
end
end
if erreurs_wt == "" then return "" end
if type(titre) == "string" then erreurs_wt = '<br/>' .. titre .. '<br/>' .. erreurs_wt end
return erreurs_wt
end
-----------------------------
-- Argts object table start
-----------------------------
local Argts = {
args_known_default = {
-- Argts in order without names, with their keyword for use as others arguments
-- Argts dans l'ordre, non nommés, avec leur keyword pour traitement comme les autres arguments
--[ [
"lastname", -- 1
"firstname", -- 2
"birthyear", -- 3
"deathyear", -- 4
--] ]
-- The arguments for authority records are treated separately
-- Les arguments pour les notices d'autorités sont traités à part
-- special arguments to modify the fonctions and outputs of this module
-- arguments speciaux pour modifier le fonctionnement et les sorties de ce module
c = {val = "", typ = "opt", need = "0", list = 1,
keyword = "c", old = "ws-catview"},
options = {val = "", typ = "opt", need = "0", list = 1,
keyword = "options", old = "ws-options"},
-- All arguments have a keyword parameter identical to the registration name, except synonyms
-- Tous les arguments ont un parametre keyword identique au nom d'enregistrement, sauf les synonymes
lastname = {val = "", typ = "dat", need = "1", list = 2,
keyword = "lastname", old = "ws-name"},
initiale = {val = "", typ = "dat", need = "1", list = 2,
keyword = "initiale", old = "ws-initiale"},
familyname = {val = "", typ = "dat", need = "0", list = 9,
keyword = "familyname", old = "ws"},
firstname = {val = "", typ = "dat", need = "0", list = 2,
keyword = "firstname", old = "ws-firstname"},
pseudonym = {val = "", typ = "ctr", need = "0", list = 9,
keyword = "pseudonym", old = "ws"},
title = {val = "", typ = "dat", need = "0", list = 9,
keyword = "title", old = "ws"},
Galliname = {val = "", typ = "dat", need = "0", list = 9,
keyword = "Galliname", old = "ws-firstgall"},
sex = {val = "", typ = "dat", need = "0", list = 9,
keyword = "sex", old = "sexe"},
sortkey = {val = "", typ = "dat", need = "0", list = 9,
keyword = "sortkey", old = "ws-key"},
image = {val = "", typ = "ctr", need = "0", list = 2,
keyword = "image", old = "ws-image"},
birthyear = {val = "", typ = "dat", need = "0", list = 2,
keyword = "birthyear", old = "ws-naissance ws_birthdate"},
birth = {val = "", typ = "syn", need = "0", list = 1,
keyword = "birthyear", old = "ws-naissance"},
birthcentury = {val = "", typ = "dat", need = "0", list = 2,
keyword = "birthcentury", old = "siecleNaissance"},
birthuncertain ={val = "", typ = "dat", need = "0", list = 3,
keyword = "birthuncertain", old = "incertitudeNaissance"},
deathyear = {val = "", typ = "dat", need = "0", list = 2,
keyword = "deathyear", old = "ws-deces ws_deathdate"},
death = {val = "", typ = "syn", need = "0", list = 1,
keyword = "deathyear", old = "ws-deces"},
deathcentury = {val = "", typ = "dat", need = "0", list = 2,
keyword = "deathcentury", old = "siecleNaissance"},
deathuncertain ={val = "", typ = "dat", need = "0", list = 3,
keyword = "deathuncertain", old = "incertitudeDeces"},
description = {val = "", typ = "ctr", need = "0", list = 1,
keyword = "description", old = "ws_description"},
occupation = {val = "", typ = "ctr", need = "0", list = 3,
keyword = "occupation", old = "ws-metier"},
genre = {val = "", typ = "ctr", need = "0", list = 3,
keyword = "genre", old = "ws-genre"},
language = {val = "", typ = "ctr", need = "0", list = 3,
keyword = "language", old = "ws-language"},
country = {val = "", typ = "ctr", need = "0", list = 3,
keyword = "country", old = "ws-country"},
prize = {val = "", typ = "ctr", need = "0", list = 4,
keyword = "prize", old = "ws-prix"},
rights = {val = "", typ = "ctr", need = "0", list = 1,
keyword = "rights", old = "rights"},
wikipedia = {val = "", typ = "ctr", need = "0", list = 2,
keyword = "wikipedia", old = "ws-wikipedia"},
wikiquote = {val = "", typ = "ctr", need = "0", list = 2,
keyword = "wikiquote", old = "ws-wikiquote"},
commons = {val = "", typ = "ctr", need = "0", list = 2,
keyword = "commons", old = "ws-commons"},
commonscat = {val = "", typ = "ctr", need = "0", list = 3,
keyword = "commonscat", old = "ws-commons-category"},
namespace = {val = "", typ = "ctr", need = "1", list = 4,
keyword = "namespace", old = "ws-namespace"},
category = {val = "", typ = "ctr", need = "0", list = 3,
keyword = "category", old = "ws-category"},
-- arguments for notices's properties
ARC = {val = "", typ = "not", need = "0", list = 3,
keyword = "ARC", old = "ws-ARC"},
ARCid = {val = "", typ = "not", need = "0", list = 3,
keyword = "ARCid", old = "ws-ARCid"},
ARCitem = {val = "", typ = "not", need = "0", list = 3,
keyword = "ARCitem", old = "ws-ARCitem"},
ARCorg = {val = "", typ = "not", need = "0", list = 3,
keyword = "ARCorg", old = "ws-ARCorg"},
ARCsub = {val = "", typ = "not", need = "0", list = 3,
keyword = "ARCsub", old = "ws-ARCsub"},
BNF = {val = "", typ = "not", need = "0", list = 3,
keyword = "BNF", old = "ws-BNF"},
GKD = {val = "", typ = "not", need = "0", list = 3,
keyword = "GKD", old = "ws-GKD"},
GKD_V1 = {val = "", typ = "not", need = "0", list = 3,
keyword = "GKD_V1", old = "ws-GKD-V1"},
IA = {val = "", typ = "not", need = "0", list = 3,
keyword = "IA", old = "ws-IA"},
ARCHIVE = {val = "", typ = "not", need = "0", list = 3,
keyword = "ARCHIVE", old = "ws-ARCHIVE"},
IBL = {val = "", typ = "not", need = "0", list = 3,
keyword = "IBL", old = "ws-IBL"},
IBLid = {val = "", typ = "not", need = "0", list = 3,
keyword = "IBLid", old = "ws-IBLid"},
IBLbook = {val = "", typ = "not", need = "0", list = 3,
keyword = "IBLbook", old = "ws-IBLbook"},
ISBN = {val = "", typ = "not", need = "0", list = 3,
keyword = "ISBN", old = "ws-ISBN"},
ISFDB = {val = "", typ = "not", need = "0", list = 3,
keyword = "ISFDB", old = "ws-ISFDB"},
ISFDBid = {val = "", typ = "not", need = "0", list = 3,
keyword = "ISFDBid", old = "ws-ISFDBid"},
ISFDBpub = {val = "", typ = "not", need = "0", list = 3,
keyword = "ISFDBpub", old = "ws-ISFDBpub"},
ISFDBtitle = {val = "", typ = "not", need = "0", list = 3,
keyword = "ISFDBtitle", old = "ws-ISFDBtitle"},
LCCN = {val = "", typ = "not", need = "0", list = 3,
keyword = "LCCN", old = "ws-LCCN"},
LT = {val = "", typ = "not", need = "0", list = 3,
keyword = "LT", old = "ws-LT"},
OCLC = {val = "", typ = "not", need = "0", list = 3,
keyword = "OCLC", old = "ws-OCLC"},
OL = {val = "", typ = "not", need = "0", list = 3,
keyword = "OL", old = "ws-OL"},
PND = {val = "", typ = "not", need = "0", list = 3,
keyword = "PND", old = "ws-PND"},
SELIBR = {val = "", typ = "not", need = "0", list = 3,
keyword = "SELIBR", old = "ws-SELIBR"},
SUDOC = {val = "", typ = "not", need = "0", list = 3,
keyword = "SUDOC", old = "ws-SUDOC"},
SWD = {val = "", typ = "not", need = "0", list = 3,
keyword = "SWD", old = "ws-SWD"},
ULAN = {val = "", typ = "not", need = "0", list = 3,
keyword = "ULAN", old = "ws-ULAN"},
VIAF = {val = "", typ = "not", need = "0", list = 3,
keyword = "VIAF", old = "ws-VIAF"},
WORLDCATID = {val = "", typ = "not", need = "0", list = 3,
keyword = "WORLDCATID", old = "ws-WORLDCATID"},
XXX = {val = "", typ = "not", need = "0", list = 3,
keyword = "XXX", old = "ws-XXX"},
-- arguments managed only by program, not read from template
-- prm.arg_memorize("catspace", frame:preprocess("{{ns:Category}}")) -- memorize the localized namespace "Category"
catspace = {val = "", typ = "prg", need = "0", list = 9,
keyword = "catspace", old = "catspace"},
}, -- local Argts args_known_default
--[[ nameList of notices's properties
-->|ARCid|ARCitem|ARCorg|ARCsub<!--
-->|ARC=National Archives and Records Administration<!--
-->|BNF=Bibliothèque nationale de France<!--
-->|GKD|GKD-V1=Gemeinsame Kšrperschaftsdatei<!--
-->|IA|ARCHIVE=Internet Archive<!--
-->|IBL|IBLid|IBLbook=Internet Book List<!--
-->|ISBN=International Standard Book Number<!--
-->|ISFDBid|ISFDBpub|ISFDBtitle<!--
-->|ISFDB=Internet Speculative Fiction Database<!--
-->|LCCN=Numéro de contrôle de la Bibliothèque du Congrès<!--
-->|LT=Library Thing<!--
-->|OCLC=Online Computer Library Center<!--
-->|OL=Open Library<!--
-->|PND=Personennamendatei<!--
-->|SELIBR=National Library of Sweden<!--
-->|SUDOC=Système universitaire de documentation<!--
-->|SWD=Schlagwortnormdatei<!--
-->|ULAN=Union List of Artist Names<!--
-->|VIAF=Fichier d'autorité international virtuel<!--
-->|WORLDCATID=WorldCat<!--
-->|XXX=XXX autorité<!--
-->|#default={{{wp|{{{3|}}} }}} <!--
--]]
args_source_example = { categoryEN = "cat author", imageEN = "Smith.jpg", prize = "Nobel", categorie = "catAuteur", image = "Franc.jpg", prix = "NobelFr", categoria = "catAuteur", imagen = "Espangnol.jpg", premio = "NobelES", },
args_known = nil,
args_source = nil,
-- prototype = {args_known = Argts.args_known_default, args_source = Argts.args_source_example, arg_lang = {{CONTENTLANG}}, },
mt = {},
mt_index = function (table, key)
return Argts.prototype[key]
end,
invoke_options = "",
debug_options = "",
} -- local Argts
-----------------------------
-- Argts object table end
-----------------------------
-- local current_space = mw.site.namespaces.name -- present namespace from system
local current_space = "" -- frame:preprocess("{{ns:0}}") -- Module namespace from system
local module_space = "" -- frame:preprocess("{{ns:Module}}") -- Module namespace from system
local template_space = "" -- frame:preprocess("{{ns:Template}}") -- Template namespace from system
local author_space = "" -- frame:preprocess("{{ns:Author}}") -- Category namespace from system
local category_space = "" -- frame:preprocess("{{ns:Category}}") -- Category namespace from system
-- Variables et fonctions de base utiles partout
local catView = "" -- = ":" to display a category to document it rather than truly categorize
-- Argts.doc_args_import_all -- Documentation des arguments dés leur lecture
-- Options de maitrise du fonctionnement de ce module
Argts.invoke_options = " " -- options normales venant du modèle, normal options from template
-- options=fr params docavant doc-min docmax docdef docnotice doc-apres docligne
-- local debug_options = " " -- pas d'options de debug du module par edit
Argts.debug_options = " unitest debug erreurs params docavant no-box no-cat doc-min doc-max doc-notice doc-def docligne not-ices tra-ck " -- options de debug du module par edit
function Argts.option(key, opt)
-- if option("nocat") then cat = "" end -- utilisation exemple simple
-- Si le mot cle key est parmi les mots options, repondre true
-- Chercher dans invoke_options et ( soit opt, soit debug_options )
-- Options de documentation : docmin docmax docnotice docdef docligne docavant docapres params
-- Autres options : en es fr unitest notices nobox nocat track
-- Veiller à toujours séparer les mots par des espaces
-- On peut désactiver les options en supprimant les mots clés ou en les coupant.
-- Les identifiants de langues permettent de forcer certaines langues.
-- Les erreurs n'apparaissent que dans les espaces de noms Modèle ou Module.
if type(key) ~= "string" then return false end
local options = " " .. Argts.invoke_options .. " "
if type(opt) == "string"
then options = options .. opt .. " " -- options du modèle et de l'appel si définies
else options = options .. Argts.debug_options .. " " end -- options du modèle et de debug sinon
key = " " .. key .. " " -- chercher les mots clefs exacts et non ceux inclus dans un autre mot
local n = string.find(options, key)
-- si le mot cle est parmi les mots options, repondre true
return ( nil ~= n )
end -- local option = function(key, opt)
function Argts.options_change(old, new, chg)
-- invoke_options = options_change(invoke_options, Argts.argv("options", tr), "init")
-- invoke_options = options_change(invoke_options, debug_options, "test")
if chg == nil then
-- if type(old) == "string" then
return old
else
-- if type(new) == "string" then
return new
end
return ""
end -- local options_change = function(chg, old, new)
Argts.trc = "<br/>* Modele:Auteur trace "
Argts.trck_on = false
function Argts.trck(x)
if Argts.trck_on then trc = trc .. tostring(x) end
end
function Argts.init_args(_known, _source, _lang) -- initialize all the values to "" in arg table
-- init_args(args_known, args_source, "fr")
local args_known_default = Argts.args_known_default
local args_known = Argts.args_known
local args_source = Argts.args_source_example -- arguments sources au niveau du module
local trck = Argts.trck
-- category_space = frame:preprocess("{{ns:Category}}") -- {{ns:Category}}
-- prm.arg_memorize("catspace", frame:preprocess("{{ns:Category}}")) -- memorize the localized namespace "Category"
trck('<br/>* init_args default args_known_default=' .. tostring(args_known_default) )
trck(', args_known=' .. tostring(args_known) )
trck(', args_source_example=' .. tostring(Argts.args_source_example) )
trck(', Argts.args_source=' .. tostring(args_source) )
trck(', Argts["args_source"]=' .. tostring(Argts["args_source"]) )
trck(', module.args_source_example.image=' .. tostring(Argts["args_source_example"]["image"]) )
trck('<br/> current_space=' .. tostring(current_space) )
trck(', module_space=' .. tostring(module_space) )
trck(', template_space=' .. tostring(template_space) )
trck(', author_space=' .. tostring(author_space) )
trck(', category_space=' .. tostring(category_space) )
trck(', arg_lang=' .. tostring(arg_lang) )
if args_known_default ~= nil then
args_known = args_known_default
Argts.args_known = args_known
end
if _known ~= nil then
args_known = _known
Argts.args_known = args_known
end
if Argts.args_source_example ~= nil then
args_source = Argts.args_source_example
Argts.args_source = args_source
end
if _source ~= nil then
args_source = _source
Argts.args_source = args_source
end
-- arg_lang = {{CONTENTLANG}} -- langue du wiki par defaut
Trad.init_lang( {{CONTENTLANG}} )
if type(_lang) == "string" then
arg_lang = _lang
end
--if arg_lang == "en" then args_trad = Trad_en end
--if arg_lang == "es" then args_trad = Trad_es end
--if arg_lang == "fr" then args_trad = Trad_fr end
-- if type(_lang) == "string"
-- then arg_lang = _lang
-- else arg_lang = {{CONTENTLANG}} end
-- if Argts.option("en") then arg_lang = "en" end
-- if Argts.option("es") then arg_lang = "es" end
-- if Argts.option("fr") then arg_lang = "fr" end
-- args_trad = Trad[arg_lang]
trck('<br/>* init_args usual args_known=' .. tostring(Argts.args_known) )
trck(', module.args_source.image=' .. tostring(args_source["image"]) )
trck(', arg_lang=' .. tostring(arg_lang) )
trck(', catspace=' .. tostring(category_space) )
trck(', author_space=' .. tostring(author_space) )
end -- Argts.init_args(_known, _source, _lang)
function Argts.arg_memorize(argname, argval, tr) -- memorize the value in local table
-- arg_memorize("firstname", "Victor")
local args_known = Argts.args_known
local trck = Argts.trck
if tr ~= nil then trck(', arg_memorize call argname='..argname..', argval='..argval) end
if argname == nil then return "" end
if argval == nil then return "" end
local arg_to_mem = args_known[argname]
if arg_to_mem == nil then return "" end
arg_to_mem["val"] = argval
local keyword = arg_to_mem["keyword"]
return argname, argval
end -- Argts.arg_memorize(argname, argval, tr)
-- try all a function, argname to skip if unknown
function Argts.argv(argname, tr) -- read arg value from local data, tr = with debug track
-- arg = Argts.argv("name") -- read the argument from local memory, no matter the language of the wiki
-- arg = Argts.argv("name", "tr") -- the same, with a text track of the debug
local args_known = Argts.args_known
local trck = Argts.trck
if tr ~= nil then trck(', argv call argname='..tostring(argname) ) end
if type(argname) ~= "string" then return "" end
if args_known[argname] == nil then return "" end
--[[
if args_known[argname]["typXXX"] == "dat" then
local keyword = args_known[argname]["keyword"]
if tr ~= nil then trc=trc..', dat keyword='..tostring(keyword) end
if keyword == nil then return "" end
local _known = tostring(args_known[argname]["val"])
local _data = tostring(Argts.argv(keyword))
if tr ~= nil then trc=trc..', _known='.._known..', _data='.._data end
return Argts.argv(keyword)
end
if args_known[argname]["typXXX"] == "ctr" then
local keyword = args_known[argname]["keyword"]
if tr ~= nil then trc=trc..', ctr keyword='..tostring(keyword) end
if keyword == nil then return "" end
local _known = tostring(args_known[argname]["val"])
local _ctr = tostring(Argts.argv(keyword))
if tr ~= nil then trc=trc..', _known='.._known..', _ctr='.._ctr end
return Argts.argv(keyword)
end
if args_known[argname]["typXXX"] == "xxx" then
local keyword = args_known[argname]["keyword"]
if tr ~= nil then trc=trc..', ctr val='..Argts.argv(keyword) end
return Argts.argv(keyword)
end
--]]
return args_known[argname]["val"] or ""
end -- Argts.argv(argname, tr)
function Argts.arg_input(args_src, argname, tr)
-- multilingual read an arg from the template, memorize it, tr = with debug track
-- arg_input(args_src, "firstname")
-- verify params, and convert nil to ""
local args_known = Argts.args_known
local trck = Argts.trck
if args_src == nil then args_src = Argts.args_source end
if tr ~= nil then trck(', _known='.._known..', _ctr='.._ctr) end
local max = table.getn(args_src)
if tr ~= nil then trck('<br/>* arg_input '..', args_known_default='..tostring(Argts.args_known_default)..', args_known='..tostring(args_known)..', args_src='..tostring(args_src)..', max='..tostring(max) ) end
local max = table.getn(args_src)
if tr ~= nil then trck('<br/>* arg_input max='..tostring(max)..', argname='..tostring(argname) ) end
if type(argname) ~= "string" then argname = "" end
if tr ~= nil then trck(', argname?='..tostring(argname) ) end
if argname == "" then return "" end
-- MW.log( ' arg_input argname='..tostring(argname)..', arg_lang='..tostring(arg_lang) ) -- trace to console
-- args_known = Argts.args_known
local argname_ = Argts.args_known[argname]
if tr ~= nil then trck(', args_known[argname]='..tostring(args_known[argname]) ) end
if argname_ == nil then return "" end
arglingual = args_trad[argname] -- multilingual name of the arg in the template
if type(arglingual) ~= "string" then arglingual = argname end
if tr ~= nil then trck(', arglingual?='..tostring(arglingual) ) end
if type(arglingual) ~= "string" then arglingual = "" end
if arglingual == "" then return "" end
if tr ~= nil then trck(', arglingual='..tostring(arglingual) ) end
local argval = args_src[arglingual] -- multilingual read the arg from the template
if type(argval) ~= "string" then argval = "" end
if tr ~= nil then trck(', argval='..tostring(argval) ) end
Argts.arg_memorize(argname, argval) -- memorize the value in local table
return trc
-- local t = Trad[arg_lang][argname]
end -- function Argts.arg_input(args_src, argname, tr)
function Argts.args_import_all(args_src, args_kwn)
-- import all arguments from template, or other source
-- Argts.args_import_all(Argts.args_source_example, Argts.args_known_default)
local trck = Argts.trck
local err, er1, t2 = "", "", ""
local key, argval = "kkk", "xxx"
local argknw, arglingual = nil, ""
-- This repair a Lua bug : Argts.any_function or Argts.any_table disappears
if args_src == nil then args_src = Argts.args_source end
if args_kwn == nil then args_kwn = Argts.args_known_default end
if arg_input == nil then arg_input = Argts.arg_input end
if args_kwn == nil then return " args_kwn=nil " end
if args_src == nil then return " args_src=nil " end
local max = table.getn(args_kwn)
-- args_trad = Trad[arg_lang] -- translation of template identifier and texts
-- if arg_lang == "en" then args_trad = Trad_en end
-- if arg_lang == "es" then args_trad = Trad_es end
-- if arg_lang == "fr" then args_trad = Trad_fr end
Trad.init_lang(arg_lang)
trck('<br/>* args_import_all '..', args_known_default='..tostring(Argts.args_known_default) )
trck(', args_known='..tostring(args_known)..', args_kwn='..tostring(args_kwn) )
trck(', args_source='..tostring(args_source)..', args_src='..tostring(args_src) )
trck(',<br/>* arg_lang=' .. tostring(arg_lang) )
trck(', max='..tostring(max) )
trck(', catspace=' .. tostring(category_space) )
trck(', author_space=' .. tostring(author_space) )
local arg_found, key_found = false, false
for k, parm in pairs(args_kwn) do -- Pour tous les parametres connus
if type(parm) == "string" then -- args en ordre numerique et renvoi vers un argument nommé
key = tostring(parm)
k = k
t2 = " " .. tostring(k) .. "-"
else
key = tostring(parm["keyword"])
k = 0
t2 = ""
end -- parm["keyword"] end
arglingual = tostring(args_trad[key]) -- args_trad OK
if arglingual == "nil" then arglingual = key end
argknw = args_kwn[key]
if argknw == nil then
err = err .. erreur_add("err_internal_argument_unknown", arglingual)
else
local val_prec = tostring(argknw["val"]) -- valeur deja definie
Argts.arg_input(args_src, key) -- multilingual read an arg
local val = tostring(Argts.argv(key, tr))
-- trck( tostring(arglingual) .. ":" )
if val_prec ~= "" then
err = err .. erreur_add("err_value_re_defined", arglingual)
end
if k == 0 then -- pour les arguments nommés
argval = tostring(argknw["val"])
else -- pour les arguments dans l'ordre
argval = val
end
trck(', '..t2..tostring(key)..'['..tostring(arglingual)..']')
if argknw["typ"] == "prg" then
-- arguments managed only by program, but read from template
trck("<b>"..tostring(argval) .. "</b> . . . " )
arg_found = true
else
if type(argval) == "string" then
if key == "options" then
Argts.invoke_options = argval
trck_on = Argts.option("track")
trck(" invoke_options="..tostring(invoke_options))
if Argts.option("en") then Trad.init_lang("en") end
if Argts.option("es") then Trad.init_lang("es") end
if Argts.option("fr") then Trad.init_lang("fr") end
end
-- trck("<b>".." argval="..tostring(argval) .. "</b> . . . " )
trck(" argval="..tostring(argval) .. " . . . " )
arg_found = true
end
end
argneed = tostring(argknw["need"])
if (argval == "") and (argneed == "1") then
err = err .. erreur_add(err_value_missing, arglingual.."++")
end
end
end
if arg_found == false then
-- err = err .. erreur_add(err_none_value)
end
-- local_erreurs = local_erreurs .. err -- collecte de toutes les erreurs
if Argts.option("erreurs", debug_options) then trck(err) end
trck("<br/>")
return err
end -- function Argts.args_import_all(args_src, args_kwn)
function Argts.generDoc1(paramName, k, paramData, opt)
-- t = t .. generDoc1("nom", "ws-name", "docligne docdef")
-- Normaliser les parametres et signaler les erreurs
-- Toujours afficher quelque chose dans la documentation du module ou du modèle.
-- t = t .. " [" .. tostring(argknw) .. "/L=" .. tostring(arglingual) .. "/V=<big><b>" .. tostring(val) .. "</b></big>] ."
if type(paramName) ~= "string" then
paramName = " paramName ? "
end -- signaler l'erreur
if type(paramData) ~= "string" then paramData = " paramData ? " end -- paramètre vide, non défini
opt = " "..tostring(opt).." " -- transparent, sinon peut donner nil, non génant
-- former le texte à afficher
local retourLigne = "" -- "<br/>"
local t2=" "..tostring(k) -- .."-"
if Argts.option("docligne", opt) then retourLigne = "" end
if Argts.option("docdef", opt) and (paramData == "") then return "" end
if k ~= 0 then paramName = t2 end -- pour les parametres non nommés
return " | " .. paramName .. " = <b>" .. paramData .. "</b>" .. retourLigne
end -- function Argts.generDoc1(paramName, paramId, opt)
local Argtest = { "Rimbaud", "Arthur", options = " debug fr docavant ", 1234, droits = "70", droits = "non", gauche = "ggcchh", deces = "1357", anneeDeces = "1842", image = "Carjat Arthur Rimbaud 1872 n2.jpg", pays = "France" }
function Argts.generDoc(opt)
-- Gérer des paramètres pour la documentation du module
-- "docmax" tous les paramètres existants
-- "docmin" quelques paramètres de base
-- "docdef" seulement les paramètres définis, ayant une valeur non nulle
-- "docnotice" generer les doc des notices
-- "docligne" mettre tous les paramètres sur une seule ligne
-- This repair a Lua bug : Argts.any_function or Argts.any_table disappears
local args_kwn = Argts.args_known_default
local key, argknw, argval = "", "", ""
local t, val = "", ""
local lst = true
t = t .. "<br/>{{Auteur"
for k, parm in pairs(args_kwn) do -- Pour tous les parametres connus
val = ""
if type(parm) == "string" then -- args en ordre numerique et renvoi vers un argument nommé
key = tostring(parm)
k = k
else
key = tostring(parm["keyword"])
k = 0
end -- parm["keyword"] end
argknw = args_kwn[key]
if argknw == nil then break end
-- arglingual = tostring(Trad.txt(key))
arglingual = tostring(args_trad[key]) -- multilingual name of the arg in the template
if arglingual == "nil" then arglingual = key end
-- if arglingual type(Argts[key]) == "table" then
-- if Argts[key]["typ"] == "not" then arglingual = key end
-- t = t .. ":" .. tostring(arglingual)
-- end
val = tostring(argknw["val"])
lst = false
if Argts.option("docmin", opt) and (parm["list"] == 1) then lst = true end
if Argts.option("docdef", opt) and (val ~= "") then lst = true end
if Argts.option("docmax", opt) then lst = true end
-- t = t .. Argts.generDoc1(arglingual, val, opt)
lst = true
if lst then -- lister arg si autorisé
t = t .. Argts.generDoc1(arglingual, k, val, opt)
end
end
t = t .. "}}<br/><br/>"
-- if Argts.option("erreurs", debug_options) then t = t .. erreur_color(local_erreurs) end
return t
end -- function Argts.generDoc(opt)
function Argts.prototype()
Argts.args_known = Argts.args_known_default
Argts.args_source = Argts.args_source_example
arg_lang = {{CONTENTLANG}}
end
function Argts.new(o) -- create a new object from the class Argts
-- see : Objects Classes http://www.lua.org/pil/16.1.html
-- see : The __index Metamethod http://www.lua.org/pil/13.4.1.html
-- function Account:new (obj)
o = o or {} -- create object if user does not provide one
-- o.__index = Argts
o.mt = {}
o.mt.__index = mt_index
setmetatable(o, Argts.mt) -- self is a prototype for o
return o
end -- function Argts.new(o)
-- Interface to generate a Unitest_Scribunto unit test.
function Argts.multi_args(frame, _known, _source, _lang)
local trck = Argts.trck
Argts.trck_on = Argts.option("track")
-- local args = frame.args
-- 28/02/2013 This repair Lua bug : args = frame.args is a table but without arguments
local args = frame:getParent().args -- local pframe
Trad.init_lang( {{CONTENTLANG}} )
Argts.init_args(_known, _source, _lang) -- initialize all the values to "" in arg table
-- init_args(args_known, args_source, "fr")
-- Argts.init(frame) -- tst.init( frame, test_list, test_data )
local out = Argts.args_import_all( args )
return out
end -- function Argts.multi_args(frame, _known, _source, _lang)
local test_source = {
options = ' fr docavant ', lastXXXname = 'Voltaire', birthyear = '1999', birthyear = '2000',
} -- Arguments pour auto-test
-- Interface to generate a Unitest_Scribunto unit test.
function Argts.Argts_autotest(frame)
-- {{#invoke:Multilingual Arguments|Argts_autotest| options = ' docavant ' | lastXXXname = Montaigne| birthyear = 1999 | birthyear = 1533 }}
local args = frame:getParent().args -- local pframe
Trad.init_lang( {{CONTENTLANG}} )
Argts.trck_on = Argts.option("track")
Argts.init_args() -- initialize all the values to "" in arg table
local test = Argts.args_import_all(test_source)
local doc = Argts.generDoc()
return test .. doc
-- local content = mw.title.getContent()
-- local test = frame:preprocess("{{#invoke:Multilingual Arguments|multi_args| lastname = Montaigne | birthyear = 1533 }}")
end -- function Argts.multi_args(frame, _known, _source, _lang)
-- local MultiArgs = require "Module:Multilingual Arguments"
return Argts