Module:Lang: Difference between revisions
Jump to navigation
Jump to search
+translation user styling;
m (1 revision imported) |
(+translation user styling;) |
||
| Line 11: | Line 11: | ||
local yesno = require ('Module:Yesno'); | local yesno = require ('Module:Yesno'); | ||
local lang_data = mw.loadData ('Module:Lang/data'); | local sandbox = (mw.getCurrentFrame():getTitle():match ('/sandbox') or ''); -- when called from a sandbox template or module load sandbox data and sandbox configuration | ||
local lang_data = mw.loadData ('Module:Lang/data' .. sandbox); -- language name override and transliteration tool-tip tables | |||
local lang_name_table = lang_data.lang_name_table; -- language codes, names, regions, scripts, suppressed scripts | local lang_name_table = lang_data.lang_name_table; -- language codes, names, regions, scripts, suppressed scripts | ||
local lang_table = lang_data.lang_name_table.lang; | local lang_table = lang_data.lang_name_table.lang; | ||
| Line 23: | Line 25: | ||
local synonym_table = mw.loadData ('Module:Lang/ISO 639 synonyms'); -- ISO 639-2/639-2T code translation to 639-1 code | local synonym_table = mw.loadData ('Module:Lang/ISO 639 synonyms'); -- ISO 639-2/639-2T code translation to 639-1 code | ||
local cfg = mw.loadData ('Module:Lang/configuration' .. | local cfg = mw.loadData ('Module:Lang/configuration' .. sandbox); -- for internationalization | ||
local is_latn_data = mw.loadData ('Module:Lang/data/is latn data'); | local is_latn_data = mw.loadData ('Module:Lang/data/is latn data'); | ||
| Line 83: | Line 85: | ||
local category_link = ((0 == namespace or 10 == namespace) and not args_t.nocat) and substitute ('[[Category:$1]]', {category}) or ''; | local category_link = ((0 == namespace or 10 == namespace) and not args_t.nocat) and substitute ('[[Category:$1]]', {category}) or ''; | ||
return substitute ('[$1] <span style="color:#d33">$2: | return substitute ('[$1] <span style="color:#d33">$2: {{$3}}: $4 ([[:Category:$5|$6]])</span>$7', -- { prevents template name from being treated as a template call in certain situations | ||
{ | { | ||
text or cfg.make_error_msg_t.undefined, | text or cfg.make_error_msg_t.undefined, | ||
| Line 1,281: | Line 1,283: | ||
table.insert (translation_t, " </small>"); -- close the <small> HTML tag | table.insert (translation_t, " </small>"); -- close the <small> HTML tag | ||
end | end | ||
table.insert (translation_t, table.concat ({' | table.insert (translation_t, table.concat ({ -- user styling spans match spand from {{gloss}} | ||
'<span class="gloss-quot">\'</span>', -- user styling span for quote marks; use HTML entities to avoid wiki markup confusion | |||
'<span class="gloss-text">', -- open user styling span for the translation | |||
args_t.translation, -- the translation | |||
'</span>', -- close user styling span for the translation | |||
'<span class="gloss-quot">\'</span>' -- user styling span for quote marks | |||
})); | |||
return table.concat (translation_t); -- make a big string and done | return table.concat (translation_t); -- make a big string and done | ||
end | end | ||
| Line 1,351: | Line 1,359: | ||
if args[text_idx] and args.text then | if args[text_idx] and args.text then | ||
return make_error_msg (substitute (cfg.lang_t.conflict_n_param, { | return make_error_msg (substitute (cfg.lang_t.conflict_n_param, {text_idx, cfg.lang_t.conflict_n_param_types.text}), args, template); | ||
else | else | ||
args.text = args[text_idx] or args.text; -- prefer positional 'text' parameter | args.text = args[text_idx] or args.text; -- prefer positional 'text' parameter | ||
| Line 1,373: | Line 1,381: | ||
if args[xlate_idx] and (args.translation or args.lit) then | if args[xlate_idx] and (args.translation or args.lit) then | ||
return make_error_msg (substitute (cfg.lang_xx_t.conflict_n_lit, { | return make_error_msg (substitute (cfg.lang_xx_t.conflict_n_lit, {xlate_idx}), args, template); | ||
elseif args.translation and args.lit then | elseif args.translation and args.lit then | ||
return make_error_msg (cfg.lang_xx_t.conflict_lit, args, template); | return make_error_msg (cfg.lang_xx_t.conflict_lit, args, template); | ||