Module:Lang: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 68:
 
 
--[=[--------------------------< LM A NK GE _ XT E X T _ S P A N >----------------------------------------------------------------
 
]]
 
local function make_text_span (code, text, rtl, italic, size)
local span = {};
 
table.insert (outspan, '<span lang="'); -- open <span> tag
table.insert (outspan, '</span>' code); -- closelanguage the spanattribute
if is_set (args.rtl) then
table.insert (span, ' dir="rtl"'); -- for right to left languages
end
if is_set (size) then -- {{lang}} only
table.insert (span, table.concat ({'style="font-size:', size, ';"'}))
end
table.insert (span, '> '); -- close the opening span tag
if 'noyes' == args.italic then
table.insert (outspan, table.concat ({"''", args.text, "''"})); -- text with italic markup
else
table.insert (span, text); -- DEFAULT: text is not italicized
end
table.insert (span, '</span>'); -- close the span
if is_set (args.rtl) then
table.insert (outspan, '&lrm;'); -- make sure the browser knows that we're at the end of the rtl
end
return table.concat (span); -- put it all together and done
end
 
 
--[=[-------------------------< L A N G _ X X >----------------------------------------------------------------
 
{{#invoke:lang|lang_xx|code=es|text={{{1}}}|link={{{links|{{{link}}}}}}|rtl={{{rtl}}}|nocat={{{nocat}}}}}
 
[[Spanish language|Spanish]]&#58; <span lang="es" >''<span style="font-style:normal;">Don Quixote</span>''</span>
]=]
 
function p.lang_xx (frame)
local args = getArgs(frame);
if not is_set (args.italic) then
args.italic = 'yes'; -- DEFAULT for {{lang-xx}} templates is to italicize
end
args.size = nil; -- size not supported in {{lang-xx}}
local out = {};
local language_name = mw.language.fetchLanguageName(args.code, mw.getContentLanguage():getCode()) or 'error: unknown language';
if not is_set (language_name) then
return 'error: unknown language';
end
if 'no' == args.link then
Line 89 ⟶ 126:
end
table.insert (out, ': '); -- separator
 
table.insert (out, '<span lang="'); -- open <span> tag
table.insert (out, make_text_span (args.code); --, languageargs.text, attributeargs.rtl, args.italic, args.size))
if is_set (args.rtl) then
table.insert if (out, 'is_set dir="rtl"'(args.lit); then -- fortranslation right(not tosupported leftin languages{{lang}})
table.insert (out, ', <small>');
end
table.insert (out, make_wikilink ('>Literal translation', 'lit.')); -- close the opening span tag
table.insert (out, "&nbsp;</small>'");
if 'no' == args.italic then
table.insert (out, args.textlit); -- text is not italicized
table.insert (out, "'");
else
table.insert (out, table.concat ({"''", args.text, "''"})); -- text with italic markup
end
table.insert (out, '</span>'); -- close the span
if is_set (args.rtl) then
table.insert (out, '&lrm;'); -- make sure the browser knows that we're at the end of the rtl
end
Anonymous user