Module:languages: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 110: Line 110:
local export = {}
local export = {}


local debug_track_module = "Module:debug/track"
local etymology_languages_data_module = "Module:etymology languages/data"
local etymology_languages_data_module = "Module:etymology languages/data"
local families_module = "Module:families"
local families_module = "Module:families"
Line 166: Line 165:
check_object = require(utilities_module).check_object
check_object = require(utilities_module).check_object
return check_object(...)
return check_object(...)
end
local function debug_track(...)
debug_track = require(debug_track_module)
return debug_track(...)
end
end


Line 302: Line 296:
return uupper(...)
return uupper(...)
end
end
local function track(page)
debug_track("languages/" .. page)
return true
end


local function normalize_code(code)
local function normalize_code(code)
Line 490: Line 479:
else
else
text, fail, cats = module[function_name](sc:toFixedNFD(text), self, sc)
text, fail, cats = module[function_name](sc:toFixedNFD(text), self, sc)
end
-- TODO: get rid of the `fail` and `cats` return values.
if fail ~= nil then
track("fail")
track("fail/" .. self._code)
end
if cats ~= nil then
track("cats")
track("cats/" .. self._code)
end
end
else
else
Line 1,558: Line 1,538:
if (not text) or text == "" then
if (not text) or text == "" then
return text, nil, {}
return text, nil, {}
end
if match(text, "<[^<>]+>") then
track("track HTML tag")
end
end
-- Remove directional characters, soft hyphens, strip markers and HTML tags.
-- Remove directional characters, soft hyphens, strip markers and HTML tags.
Line 1,651: Line 1,628:
:gsub("\4", ":")
:gsub("\4", ":")
end
end
--[[if not self:hasType("conlang") then
text = gsub(text,"^%*", "")
end
text = gsub(text,"^%*%*", "*")]]


return text, fail, cats, subbedChars
return text, fail, cats, subbedChars
Line 1,688: Line 1,672:
sc = checkScript(text, self, sc)
sc = checkScript(text, self, sc)
if not (sc:isTransliterated() or module_override) then
if not (sc:isTransliterated() or module_override) then
-- temporary tracking to see if/when this gets triggered
track("non-transliterable")
track("non-transliterable/" .. self._code)
track("non-transliterable/" .. sc:getCode())
track("non-transliterable/" .. sc:getCode() .. "/" .. self._code)
return nil, true, {}
return nil, true, {}
end
end
Line 1,736: Line 1,715:
return m1 .. uupper(m2)
return m1 .. uupper(m2)
end)
end)
end
-- Track module overrides.
if module_override ~= nil then
track("module_override")
end
end


Line 2,071: Line 2,045:
--[==[Finds the language whose code matches the one provided. If it exists, it returns a <code class="nf">Language</code> object representing the language. Otherwise, it returns {{code|lua|nil}}, unless <code class="n">paramForError</code> is given, in which case an error is generated. If <code class="n">paramForError</code> is {{code|lua|true}}, a generic error message mentioning the bad code is generated; otherwise <code class="n">paramForError</code> should be a string or number specifying the parameter that the code came from, and this parameter will be mentioned in the error message along with the bad code. If <code class="n">allowEtymLang</code> is specified, etymology-only language codes are allowed and looked up along with normal language codes. If <code class="n">allowFamily</code> is specified, language family codes are allowed and looked up along with normal language codes.]==]
--[==[Finds the language whose code matches the one provided. If it exists, it returns a <code class="nf">Language</code> object representing the language. Otherwise, it returns {{code|lua|nil}}, unless <code class="n">paramForError</code> is given, in which case an error is generated. If <code class="n">paramForError</code> is {{code|lua|true}}, a generic error message mentioning the bad code is generated; otherwise <code class="n">paramForError</code> should be a string or number specifying the parameter that the code came from, and this parameter will be mentioned in the error message along with the bad code. If <code class="n">allowEtymLang</code> is specified, etymology-only language codes are allowed and looked up along with normal language codes. If <code class="n">allowFamily</code> is specified, language family codes are allowed and looked up along with normal language codes.]==]
function export.getByCode(code, paramForError, allowEtymLang, allowFamily)
function export.getByCode(code, paramForError, allowEtymLang, allowFamily)
-- Track uses of paramForError, ultimately so it can be removed, as error-handling should be done by [[Module:parameters]], not here.
if paramForError ~= nil then
track("paramForError")
end
if type(code) ~= "string" then
if type(code) ~= "string" then
local typ
local typ
Line 2,090: Line 2,060:


local m_data = load_data(languages_data_module)
local m_data = load_data(languages_data_module)
if m_data.aliases[code] or m_data.track[code] then
track(code)
end


local norm_code = normalize_code(code)
local norm_code = normalize_code(code)

Navigation menu