Module:Lang: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
No edit summary |
No edit summary |
||
Line 340: | Line 340: | ||
table.insert (tout, "</span>''"); |
table.insert (tout, "</span>''"); |
||
return table.concat (tout); |
return table.concat (tout); |
||
⚫ | |||
--[[--------------------------< V A L I D A T E _ T E X T >--------------------------------------------------- |
|||
]] |
|||
local function validate_text (template, args) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
|||
end |
end |
||
Line 363: | Line 396: | ||
if not (code and script and region and variant) then |
if not (code and script and region and variant) then |
||
return make_error_msg (table.concat ({'{{lang}}: unknown language code: ', args.code or 'missing'}), args. |
return make_error_msg (table.concat ({'{{lang}}: unknown language code: ', args.code or 'missing'}), args.nocat); |
||
end |
end |
||
⚫ | |||
⚫ | |||
⚫ | |||
if not is_set (args.italic) then |
if not is_set (args.italic) then |
||
args.italic = 'no'; -- DEFAULT for {{lang}} templates is to not italicize |
args.italic = 'no'; -- DEFAULT for {{lang}} templates is to not italicize |
||
end |
end |
||
local msg = validate_text ('lang', args); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
return msg; |
|||
end |
end |
||
args.code = format_ietf_tag (code, script, region, variant); -- format to recommended subtag styles |
args.code = format_ietf_tag (code, script, region, variant); -- format to recommended subtag styles |
||
Line 429: | Line 459: | ||
if not (code and script and region and variant) then |
if not (code and script and region and variant) then |
||
return make_error_msg (table.concat ({'{{lang-xx}}: unknown language code: ', args.code or 'missing'}), args. |
return make_error_msg (table.concat ({'{{lang-xx}}: unknown language code: ', args.code or 'missing'}), args.nocat); |
||
end |
end |
||
local msg = validate_text ('lang-xx', args); |
|||
⚫ | |||
if is_set (msg) then |
|||
return make_error_msg ('{{lang-xx}}: no text', args.no_cat); |
|||
return msg; |
|||
⚫ | |||
---------- |
|||
⚫ | |||
⚫ | |||
⚫ | |||
if args.text:match ("%f[\']\'\'[^\']+\'\'%f[^\']") or args.text:match ("\'\'\'\'\'[^\']+\'\'\'\'\'") then -- italic but not bold or bold italic |
|||
return make_error_msg ('{{lang-xx}}: text has italic markup', args.no_cat); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
---------- |
|||
args.code = format_ietf_tag (code, script, region, variant); -- format to recommended subtag styles |
args.code = format_ietf_tag (code, script, region, variant); -- format to recommended subtag styles |