Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:DateI18n: Difference between revisions

From Neodyland Wiki
Fulfilling edit request by CalendulaAsteraceae. Thanks for helping!
 
Line 277: Line 277:
end
end
return timeStamp, datecode
return timeStamp, datecode
end
local function isValidLangCode(lang)
if not lang then
return false
end
lang = mw.text.trim(lang)
return lang ~= '' and lang ~= '⧼Lang⧽' and mw.language.isValidCode(lang)
end
end


Line 303: Line 311:
-- set language
-- set language
if not lang or not mw.language.isValidCode(lang) then
if not isValidLangCode(lang) then
-- get user's chosen language
-- get user's chosen language
-- equivalent to {{int:lang}}
lang = mw.getCurrentFrame():callParserFunction("int", "lang")
lang = mw.getCurrentFrame():callParserFunction("int", "lang")
if not lang or not mw.language.isValidCode(lang) then
if not isValidLangCode(lang) then
-- if that doesn't work, use the project language
-- if that doesn't work, use the project language
-- this is useful on projects which import this module from Commons
-- this is useful on projects which import this module from Commons
lang = mw.language.getContentLanguage().code
lang = mw.language.getContentLanguage().code
if not lang or not mw.language.isValidCode(lang) then
if not isValidLangCode(lang) then
-- if that doesn't work, use English
-- if that doesn't work, use English
lang = "en"
lang = "en"
Line 437: Line 446:
-- default values
-- default values
-- Allows to set the html class of the time node where the date is included. This is useful for microformats.
-- Allows to set the html class of the time node where the date is included. This is useful for microformats.
args.class = args.class or 'dtstart'
args.class = args.class or '-'
if args.class == '' then
args.class = 'dtstart'
end
-- By default, pad one- and two-digit years to be 4 digits long, while keeping three-digit years as-is.
-- By default, pad one- and two-digit years to be 4 digits long, while keeping three-digit years as-is.
args.trim_year = args.trim_year or '100-999'
args.trim_year = args.trim_year or '100-999'
Cookies help us deliver our services. By using our services, you agree to our use of cookies.