local lang_obj = mw.language.getContentLanguage(); -- make a language object for the local language; used here for languages and dates
--[[--------------------------< U N C A T E G O R I Z E D _ N A M E S P A C E S >------------------------------
local et_al_patterns = {
"[;,]? *[\"']*%f[%a][Ee][Tt]%.? *[Aa][Ll][%.;,\"']*$", -- variations on the 'et al' theme
"[;,]? *[\"']*%f[%a][Ee][Tt]%.? *[Aa][Ll][Ii][AaIi][Ee]?[%.;,\"']*$", -- variations on the 'et alia', 'et alii' and 'et aliae' themes (false positive 'et aliie' unlikely to match)
"[;,]? *%f[%a]and [Oo]thers", -- an alternative to et al.
"%[%[ *[Ee][Tt]%.? *[Aa][Ll]%.? *%]%]", -- a wikilinked form
"%(%( *[Ee][Tt]%.? *[Aa][Ll]%.? *%)%)", -- a double-bracketed form (to counter partial removal of ((...)) syntax)
"[%(%[] *[Ee][Tt]%.? *[Aa][Ll]%.? *[%)%]]", -- a bracketed form
}
-- Lua patterns to match generic titles; usually created by bots or reference filling tools
-- translators: replace ['local'] = nil with lowercase translation only when bots or tools create generic titles in your language
['generic_titles'] = {
-- generic titles and patterns in this table should be lowercase only
-- leave ['local'] nil except when there is a matching generic title in your language
-- boolean 'true' for plain-text searches; 'false' for pattern searches
{['en'] = {'^wayback%s+machine$', false}, ['local'] = nil},
{['en'] = {'are you a robot', true}, ['local'] = nil},
['generic_titles'] = {
{['en'] = {'hugedomains.com', true}, ['local'] = nil},
['accept'] = {
{['en'] = {'^[%(%[{<]?no +title[>}%]%)]?$', false}, ['local'] = nil},
},
{['en'] = {'page not found', true}, ['local'] = nil},
['reject'] = {
{['en'] = {'^wayback%s+machine$subscribe to read', falsetrue}, ['local'] = nil},
{['en'] = {'are you a robot^[%(%[{<]?unknown[>}%]%)]?$', truefalse}, ['local'] = nil},
{['en'] = {'hugedomains.comwebsite is for sale', true}, ['local'] = nil},
{['en'] = {'^[%(%[{<]?no +title[>}%]%)]?$404', false}, ['local'] = nil},
{['en'] = {'pageinternet notarchive foundwayback machine', true}, ['local'] = nil},
{['en'] = {'subscribelog tointo readfacebook', true}, ['local'] = nil},
{['en'] = {'^[%(%[{<]?unknown[>}%]%)]?$login • instagram', falsetrue}, ['local'] = nil},
{['en'] = {'website is for saleredirecting...', true}, ['local'] = nil},
{['en'] = {'^404usurped title', falsetrue}, ['local'] = nil}, -- added by a GreenC bot
{['en'] = {'internetwebcite archivequery wayback machineresult', true}, ['local'] = nil},
{['en'] = {'log intowikiwix\'s facebookcache', true}, ['local'] = nil},
{['en'] = {'login • instagram', true}, ['local'] = nil},
{['en'] = {'redirecting...', true}, ['local'] = nil},
{['en'] = {'usurped title', true}, ['local'] = nil}, -- added by a GreenC bot
{['en'] = {'webcite query result', true}, ['local'] = nil},
{['en'] = {'wikiwix\'s cache', true}, ['local'] = nil},
}
},
['generic_names'] = {
-- boolean 'true' for plain-text searches, search string must be lowercase only
-- generic names and patterns in this table should be lowercase only
-- boolean 'false' for pattern searches
-- leave ['local'] nil except when there is a matching generic name in your language
-- boolean 'true' for plain-text searches; 'false' for pattern searches
{['en'] = {'about us', true}, ['local'] = nil},
['generic_names'] = {
{['en'] = {'%f[%a][Aa]dvisor%f[%A]', false}, ['local'] = nil},
['accept'] = {
{['en'] = {'%f[%a][[^|Aa]*uthor%(author%) *|f[^%]]*%]%A]', false}, ['local'] = nil},
{['en'] = {'collaborator', true}, ['local'] = nil},
},
{['en'] = {'contributor', true}, ['local'] = nil},
['reject'] = {
{['en'] = {'aboutcontact us', true}, ['local'] = nil},
{['en'] = {'%f[%a][Aa]dvisor%f[%A]directory', falsetrue}, ['local'] = nil},
{['en'] = {'%f[%a(%[][Aa%(%[]uthor%fs*eds?%.?%s*[%A)%]]?$', false}, ['local'] = nil},
{['en'] = {'collaborator[,%.%s]%f[e]eds?%.?$', truefalse}, ['local'] = nil},
{['en'] = {'contributor^eds?[%.,;]', truefalse}, ['local'] = nil},
{['en'] = {'contact us^[%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]', truefalse}, ['local'] = nil},
{['en'] = {'directory%f[%a][Ee]dited%f[%A]', truefalse}, ['local'] = nil},
{['en'] = {'%f[%(%[a][%(%[Ee]%s*edsditors?%.?%s*f[%)%A]]?$', false}, ['local'] = nil},
{['en'] = {'%f[,%.%sa]]Ee]mail%f[e]eds?%.?$A]', false}, ['local'] = nil},
{['en'] = {'^eds?[%.,;]facebook', falsetrue}, ['local'] = nil},
{['en'] = {'^[%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]google', falsetrue}, ['local'] = nil},
{['en'] = {'%f[%a][Ee]dited%f[%A]home page', falsetrue}, ['local'] = nil},
{['en'] = {'%f[%a][Ee]ditors?%f[%A]instagram', falsetrue}, ['local'] = nil},
{['en'] = {'%f[%a]]Ee]mail%f[%A]interviewer', falsetrue}, ['local'] = nil},
{['en'] = {'facebooklinkedIn', true}, ['local'] = nil},
{['en'] = {'googlepinterest', true}, ['local'] = nil},
{['en'] = {'home pagepolicy', true}, ['local'] = nil},
{['en'] = {'instagramprivacy', true}, ['local'] = nil},
{['en'] = {'interviewertranslator', true}, ['local'] = nil},
{['en'] = {'linkedIntumblr', true}, ['local'] = nil},
{['en'] = {'^[Nn]ews$twitter', falsetrue}, ['local'] = nil},
{['en'] = {'pinterestsite name', true}, ['local'] = nil},
{['en'] = {'policystatement', true}, ['local'] = nil},
{['en'] = {'privacysubmitted', true}, ['local'] = nil},
{['en'] = {'translatorsuper.?user', truefalse}, ['local'] = nil},
{['en'] = {'tumblr%f['..is_Latn..'][Uu]ser%f[^'..is_Latn..']', truefalse}, ['local'] = nil},
{['en'] = {'twitterverfasser', true}, ['local'] = nil},
}
{['en'] = {'site name', true}, ['local'] = nil},
{['en'] = {'statement', true}, ['local'] = nil},
{['en'] = {'submitted', true}, ['local'] = nil},
{['en'] = {'super.?user', false}, ['local'] = nil},
{['en'] = {'%f['..is_Latn..'][Uu]ser%f[^'..is_Latn..']', false}, ['local'] = nil},
{['en'] = {'verfasser', true}, ['local'] = nil},
}
}
}
Easter and Christmas are defined here as 98 and 99, which should be out of the
ISO 8601 (EDTF) range of uses for a while.
local_date_names_from_mediawiki is a boolean. When set to:
true – module will fetch local month names from MediaWiki for both date_names['local']['long'] and date_names['local']['short']
false – module will *not* fetch local month names from MediaWiki
Caveat lector: There is no guarantee that MediaWiki will provide short month names. At your wiki you can test
the results of the MediaWiki fetch in the debug console with this command (the result is alpha sorted):
=mw.dumpObject (p.date_names['local'])
While the module can fetch month names from MediaWiki, it cannot fetch the quarter, season, and named date names
from MediaWiki. Those must be translated manually.
]]
local local_date_names_from_mediawiki = true; -- when false, manual translation required for date_names['local']['long'] and date_names['local']['short']
-- when true, module fetches long and short month names from MediaWiki
local date_names = {
['en'] = { -- English
['named'] = {['Easter'] = 98, ['Christmas'] = 99},
},
-- when local_date_names_from_mediawiki = false
['local'] = { -- replace these English date names with the local language equivalents
['long'] = {['January'] = 1, ['February'] = 2, ['March'] = 3, ['April'] = 4, ['May'] = 5, ['June'] = 6, ['July'] = 7, ['August'] = 8, ['September'] = 9, ['October'] = 10, ['November'] = 11, ['December'] = 12},
['named'] = {['Easter'] = 98, ['Christmas'] = 99},
},
['inv_local_longinv_local_l'] = {}, -- used in date reformatting & translation; copy of date_names['local'].long where k/v are inverted: [1]='<local name>' etc.
['inv_local_shortinv_local_s'] = {}, -- used in date reformatting & translation; copy of date_names['local'].short where k/v are inverted: [1]='<local name>' etc.
['inv_local_quarter'] = {}, -- used in date translation; copy of date_names['local'].quarter where k/v are inverted: [1]='<local name>' etc.
['inv_local_season'] = {}, -- used in date translation; copy of date_names['local'].season where k/v are inverted: [1]='<local name>' etc.
['inv_local_named'] = {}, -- used in date translation; copy of date_names['local'].named where k/v are inverted: [1]='<local name>' etc.
['local_digits'] = {['0'] = '0', ['1'] = '1', ['2'] = '2', ['3'] = '3', ['4'] = '4', ['5'] = '5', ['6'] = '6', ['7'] = '7', ['8'] = '8', ['9'] = '9'}, -- used to convert local language digits to Western 0-9
['xlate_digits'] = {},
}
for name, i in pairs (date_names['local'].long) do -- this table is ['name'] = i
if local_date_names_from_mediawiki then -- if fetching local month names from MediaWiki is enabled
date_names['inv_local_l'][i] = name; -- invert to get [i] = 'name' for conversions from ymd
local long_t = {};
local short_t = {};
for i=1, 12 do -- loop 12x and
local name = lang_obj:formatDate('F', '2022-' .. i .. '-1'); -- get long month name for each i
long_t[name] = i; -- save it
name = lang_obj:formatDate('M', '2022-' .. i .. '-1'); -- get short month name for each i
short_t[name] = i; -- save it
end
date_names['local']['long'] = long_t; -- write the long table – overwrites manual translation
date_names['local']['short'] = short_t; -- write the short table – overwrites manual translation
end
-- create inverted date-name tables for reformatting and/or translation
for name, i in pairs (date_names['local'].short) do -- this table is ['name'] = i
for _, invert_t in pairs {{'long', 'inv_local_long'}, {'short', 'inv_local_short'}, {'quarter', 'inv_local_quarter'}, {'season', 'inv_local_season'}, {'named', 'inv_local_named'}} do
for name, i in pairs (date_names['localinv_local_s'][invert_t[1i]]) do= name; -- thisinvert tableto isget [i] = 'name'] =for iconversions from ymd
date_names[invert_t[2]][i] = name; -- invert to get [i] = 'name' for conversions from ymd
end
end
local function get_date_format ()
local content = mw.title.getCurrentTitle():getContent() or ''; -- get the content of the article or ''; new pages edited w/ve do not have 'content' until saved; ve does not preview; phab:T221625
local title_object = mw.title.getCurrentTitle();
if title_object.namespace == 10 then -- not in template space so that unused templates appear in unused-template-reports;
return nil; -- auto-formatting does not work in Template space so don't set global_df
end
local content = title_object:getContent() or ''; -- get the content of the article or ''; new pages edited w/ve do not have 'content' until saved; ve does not preview; phab:T221625
for _, pattern in ipairs (df_template_patterns) do -- loop through the patterns looking for {{Use dmy dates}} or {{Use mdy dates}} or any of their redirects
local start, _, match = content:find(pattern); -- match is the three letters indicating desired date format
local templates_not_using_page = {'audio-visual', 'episode', 'mailinglist', 'newsgroup', 'podcast', 'serial', 'sign', 'speech'}
--[[
These tables control when it is appropriate for {{citation}} to render |volume= and/or |issue=. The parameter
names in the tables constrain {{citation}} so that its renderings match the renderings of the equivalent cs1
templates. For example, {{cite web}} does not support |volume= so the equivalent {{citation |website=...}} must
not support |volume=.
]]
local citation_no_volume_t = { -- {{citation}} does not render |volume= when these parameters are used
'website', 'mailinglist', 'script-website',
}
local citation_issue_t = { -- {{citation}} may render |issue= when these parameters are used
'journal', 'magazine', 'newspaper', 'periodical', 'work',
'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work',
}
--[[
]]
--local this_wiki_code = mw.getContentLanguage():getCode(); -- get this wiki's language code
if string.match (mw.site.server, 'wikidata') then
local this_wiki_code = lang_obj:getCode(); -- get this wiki's language code
if string.match (mw.site.server, 'wikidata') then
this_wiki_code = mw.getCurrentFrame():preprocess('{{int:lang}}'); -- on Wikidata so use interface language setting instead
end
}
local lang_name_remap = { -- used for |language=; names require proper capitalization; tags must be lowercase
['alemannisch'] = {'Swiss German', 'gsw'}, -- not an ISO or IANA language name; MediaWiki uses 'als' as a subdomain name for Alemannic Wikipedia: als.wikipedia.org
['bangla'] = {'Bengali', 'bn'}, -- MediaWiki returns Bangla (the endonym) but we want Bengali (the exonym); here we remap
['kölsch'] = {'Kölsch', 'ksh'}, -- use IANA/ISO 639 preferred name
['ripuarian'] = {'Ripuarian', 'mis-x-ripuar'}, -- group of dialects; no code in MediaWiki or in IANA/ISO 639
['taiwanese hokkien'] = {'Taiwanese Hokkien', 'nan-twTW'}, -- make room for MediaWiki/IANA/ISO 639 nan: Min Nan Chinese
['tosk albanian'] = {'Tosk Albanian', 'als'}, -- MediaWiki replaces 'Tosk Albanian' with 'Alemannisch' so 'Tosk Albanian' cannot be found
['valencian'] = {'Valencian', 'ca'}, -- variant of Catalan; categorizes as Catalan
encode = true,
separator = ' ',
id_limit = 2301000023000000,
custom_access = 'osti-access',
},
encode = true,
separator = ' ',
id_limit = 93000009500000,
access = 'free', -- free to read
},
encode = true,
separator = ' ',
id_limit = 42000004100000,
custom_access = 'ssrn-access',
},
encode = false,
separator = ' ',
id_limit = 254000000250000000,
custom_access = 's2cid-access',
},
indic_script = indic_script,
emoji = emoji,
local_lang_cat_enable = local_lang_cat_enable,
maint_cats = maint_cats,
messages = messages,
mw_languages_by_name_t = mw_languages_by_name_t,
citation_class_map_t = citation_class_map_t,
citation_issue_t = citation_issue_t,
citation_no_volume_t = citation_no_volume_t,
}
|