Modul:Lang: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
kTidak ada ringkasan suntingan Tag: Dikembalikan Suntingan perangkat seluler Suntingan peramban seluler Suntingan seluler lanjutan |
-require('Module:No globals') |
||
(6 revisi perantara oleh 2 pengguna tidak ditampilkan) | |||
Baris 1:
--[=[
Lua support for the {{lang}}, {{lang-xx}}, and {{
▲Lua support for the {{lang}}, {{lang-xx}}, and {{transliteration}} templates and replacement of various supporting templates.
]=]
local getArgs = require ('Module:Arguments').getArgs;
Baris 105 ⟶ 101:
The return value nil causes the calling lang, lang_xx, or transl function to set args.italic according to the template's
defined default ('inherit' for {{lang}}, 'inherit' or 'italic' for {{lang-xx}} depending on
the individual template's requirements, 'italic' for {{
and {{lang-xx}} only).
Baris 414 ⟶ 410:
local category;
if '
category = '
else
category = 'Lang and lang-xx'
Baris 611 ⟶ 607:
if mw.ustring.find (language_name, 'languages', 1, true) then
return table.concat ({'[[Category:
end
table.insert (cat, '[[Category:
if this_wiki_lang_tag == code then
table.insert (cat, '
else
table.insert (cat, language_name);
end
table.insert (cat, '
return table.concat (cat);
Baris 632 ⟶ 628:
return translit <i lang=xx-Latn>...</i> where xx is the language code; else return empty string
The value |script= is not used in {{
are listed in the {{
at {{Language with name and transliteration}}. If |script= is set, this function uses it in preference to code.
Baris 643 ⟶ 639:
transl() always provides language_name, translit, and one of code or tscript, never both; always provides style
For {{
]]
Baris 705 ⟶ 701:
local close_tag;
if is_set (code) then -- when a language code is provided (always with {{lang-xx}} templates, not always with {{
if not style then -- nil for the default italic style
table.insert (out_t, "<i lang=\""); -- so use <i> tag
Baris 718 ⟶ 712:
table.insert (out_t, "-Latn\">"); -- transliterations are always Latin script
else
table.insert (out_t, "<span>"); -- when no language code: no lang= attribute, not italic ({{
close_tag = '</span>';
end
Baris 840 ⟶ 834:
If text contains <poem>...</poem> stripmarker, return text unmodified and choose <div>..</div> tags because
the stripmarker is replaced with text wrapped in <div>..</div> tags.
]]
Baris 851 ⟶ 842:
if has_poem_tag (text) then -- contains poem stripmarker (we can't know the content of that)
tag = 'div'; -- poem replacement is in div tags so lang must use div tags
elseif mw.text.trim (text):find ('\n\n+') then -- contains implied p tags
text = mw.text.trim (text); -- trim leading and trailing whitespace characters
Baris 942 ⟶ 931:
local template = args.template or 'Lang';
validate_cat_args (args); -- determine if categorization should be suppressed
Baris 1.045 ⟶ 1.031:
return _lang (args);
end▼
if 'no' == args_t.link then▼
table.insert (translation_t, '<abbr title="literal translation">lit.</abbr>'); -- unlinked form▼
else▼
table.insert (translation_t, make_wikilink ('Literal translation', 'lit.')); -- linked form▼
end▼
table.insert (translation_t, " </small>"); -- close the <small> html tag▼
table.insert (translation_t, table.concat ({''', args_t.translation, '''})); -- use html entities to avoid wiki markup confusion▼
end
Baris 1.131 ⟶ 1.092:
local template = args.template or 'Lang-xx';
if args[1] and args.text then
return make_error_msg ('conflicting: {{{1}}} and |text=', args, template);
Baris 1.226 ⟶ 1.184:
table.insert (out, make_wikilink (lang_data.article_name[code], language_name)); -- language name with wikilink from override data
else
table.insert (out, make_wikilink (
end
end
Baris 1.251 ⟶ 1.209:
translit_title = mw.title.makeTitle (0, table.concat ({'Romanization of ', translit_script_name})); -- make a title object
if translit_title.exists and ('no' ~= args.link) then
table.insert (out, make_wikilink ('Romanization of ' .. translit_script_name or language_name, '
else
table.insert (out, '
end
table.insert (out, ' </small>'); -- close the small tag
Baris 1.267 ⟶ 1.225:
if is_set (args.translation) then -- translation (not supported in {{lang}})
table.insert (out,
if 'none' ~= args.label then
table.insert (out, '<small>');
▲ table.insert (
▲ else
▲ end
▲ end
▲
end
Baris 1.438 ⟶ 1.406:
language_name = make_wikilink (lang_data.article_name[code], label or language_name); -- language name with wikilink from override data
else
language_name = make_wikilink (
end
end
Baris 1.529 ⟶ 1.497:
local msg; -- for when called functions return an error message
▲ if is_set (args[3]) then -- [3] set when {{transliteration|code|standard|text}}
args.text = args[3]; -- get the transliterated text
args.translit_std = args[2] and args[2]:lower(); -- get the standard; lower case for table indexing
if not title_table[args.translit_std] then
return make_error_msg (table.concat ({'unrecognized transliteration standard: ', args.translit_std}), args, '
end
else
if is_set (args[2]) then -- [2] set when {{
args.text = args[2]; -- get the transliterated text
else
if args[1] and
else
args.text = args[1]; -- args[1] is not a code so we're missing that; assign args.text for error message
return make_error_msg ('missing language / script code', args, '
end
end
Baris 1.554 ⟶ 1.518:
if is_set (args[1]) then -- IANA language code used for html lang= attribute; or ISO 15924 script code
if args[1]:match ('^%a%a%a?%a?$
args.code = args[1]:lower(); -- use the language/script code; only (2, 3, or 4 alpha characters)
else
return make_error_msg (table.concat ({'unrecognized language / script code: ', args[1]}), args, '
end
else
return make_error_msg ('missing language / script code', args, '
end
args.italic, msg = validate_italic (args);
if msg then
return make_error_msg (msg, args, '
end
Baris 1.574 ⟶ 1.538:
if override_table[args.code] then -- is code a language code defined in the override table?
language_name = override_table[args.code];
elseif lang_table[args.code] then -- is code a language code defined in the standard language code tables?
language_name = lang_table[args.code];
Baris 1.584 ⟶ 1.547:
args.code = ''; -- unset because not a language code
else
return make_error_msg (table.concat ({'unrecognized language / script code: ', args.code}), args, '
end
-- here only when all parameters passed to make_translit() are valid
Baris 1.663 ⟶ 1.626:
tag_from_name = tag_from_name, -- returns ietf tag associated with language name
name_from_tag = name_from_tag, -- used for template documentation; possible use in ISO 639 name from code templates
transl = transl, -- entry point for {{
_category_from_tag = _category_from_tag, -- entry points when this module is require()d into other modules
Baris 1.674 ⟶ 1.637:
_name_from_tag = _name_from_tag,
_transl = _transl,
};
|