Module:Lang: Difference between revisions

Added support for lang codes longer than 2 characters
m Undo revision 10297 by Saag (talk)
Tag: Undo
Line 1: Line 1:
local p = {}
local p = {}
-- Set of valid language codes
local lang_codes_set = {
en = true,
es = true,
['zh-hant'] = true
}


-- Overrides applied to searches by key. Designed to handle edge cases where
-- Overrides applied to searches by key. Designed to handle edge cases where
Line 167: Line 160:
     local lang_code = title.fullText:match(".*/(.*)$")
     local lang_code = title.fullText:match(".*/(.*)$")
if (lang_code == nil or lang_codes_set[lang_code]) == nil then
-- if the last part the url is not two letters, then its not a lang code,
-- so default to english
if (lang_code == nil or string.len(lang_code) ~= 2) then
return 'en'
return 'en'
end
end