Module:Infobox/utilities: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 7:
of the template doesn't work in [[Salammbô]] when |title_orig= exists but does not have a value. When that
happened, the infobox returned plain wikitext [[s:fr:Salammbô|]] which should have been a functioning link.
Placing that wikilink in the article body and previewing producesproduced a working inter-language/inter-project link.
 
{{#invoke:Infobox/utilities|interlang_wikisource_link_make|{{{orig_lang_code|}}}|{{{native_wikisource|}}}|{{{title_orig|}}}|{{{name|}}} }}
Some experimentation here showed that |title_orig= was empty string and |name= was a single space character. Why?
 
]=]
Line 21:
local title_orig = args_t[3];
local name = args_t[4];
 
if not title_orig then
return '<span style="color:#d33">missing required parameter <span style="font-family: monospace;">|title_orig=</span>';
end
 
local orig_lang_name = mw.language.fetchLanguageName (orig_lang_code, 'en'); -- get the English name associated with <orig_lang_code>; only language tags known to MediaWiki allowed
if '' == orig_lang_name then -- empty string when <orig_lang_code> invalid
return '<span style="color:#d33">invalid language tag: <span style="font-family:monospace">' .. orig_lang_code .. '</span></span>';
end
 
Line 38 ⟶ 34:
table.insert (out_t, native_wikisource); -- insert wikisource title
table.insert (out_t, '|'); -- done with link; start label
table.insert (out_t, title_orig or name or mw.title.getCurrentTitle().baseText); -- insert the label
 
-- if title_orig then -- if |title_orig= set
-- table.insert (out_t, title_orig); -- use this for the label
-- elseif name then -- if |name= set TODO: because <title_orig> is required, do we need this?
-- table.insert (out_t, name); -- use this for the label
-- else
-- table.insert (out_t, mw.title.getCurrentTitle().baseText); -- use current page name TODO: because <title_orig> is required, do we need this?
-- end
table.insert (out_t, ']]'); -- close inter-language/inter-project wikilink
Line 53 ⟶ 40:
 
table.insert (out_t, ' at '); -- begin other language wikisource wikilinklink
 
table.insert (out_t, orig_lang_name); -- add the MediaWiki-known language name associated with |orig_lang_code=
 
table.insert (out_t, ' [[Wikisource]]'); -- insert wikisource link static text