Module:languages: Difference between revisions
standardChars -> standard_chars for consistency with other fields |
No edit summary |
||
| (7 intermediate revisions by the same user not shown) | |||
| Line 875: | Line 875: | ||
function Language:makeWikipediaLink() | function Language:makeWikipediaLink() | ||
return make_link(self, (self:hasType("conlang") and self:getCanonicalName() or "w:" .. self:getWikipediaArticle()), self:getCanonicalName()) | |||
end | end | ||
| Line 882: | Line 882: | ||
Language.getCommonsCategory = require(language_like_module).getCommonsCategory | Language.getCommonsCategory = require(language_like_module).getCommonsCategory | ||
return self:getCommonsCategory() | return self:getCommonsCategory() | ||
end | |||
function Language:getMainCategoryName() | |||
return self._data.main_category or "lemma" | |||
end | end | ||
| Line 961: | Line 965: | ||
first_sc = get_script(first_sc) | first_sc = get_script(first_sc) | ||
local charset = first_sc.characters | local charset = first_sc.characters | ||
return charset and umatch(text, "[" .. charset .. "]") and first_sc or get_script("None") | |||
return charset and umatch(text, "[" .. ugsub(charset, "%]", "%%]") .. "]") and first_sc or get_script("None") | |||
end | end | ||
| Line 1,016: | Line 1,021: | ||
-- Count characters by removing everything in the script's charset and comparing to the original length. | -- Count characters by removing everything in the script's charset and comparing to the original length. | ||
local charset = sc.characters | local charset = sc.characters | ||
local count = charset and length - ulen((ugsub(text, "[" .. charset .. "]+", ""))) or 0 | local count = charset and length - ulen((ugsub(text, "[" .. charset:gsub("%]", "%%]") .. "]+", ""))) or 0 | ||
if count >= length then | if count >= length then | ||
| Line 1,913: | Line 1,918: | ||
-- Incomplete transliterations return nil. | -- Incomplete transliterations return nil. | ||
local charset = sc.characters | local charset = sc.characters | ||
if charset and umatch(text, "[" .. charset .. "]") then | if charset and umatch(text, "[" .. charset:gsub("%]", "%%]") .. "]") then | ||
-- Remove any characters in Latin, which includes Latin characters also included in other scripts (as these are | -- Remove any characters in Latin, which includes Latin characters also included in other scripts (as these are | ||
-- false positives), as well as any PUA substitutions. Anything remaining should only be script code "None" | -- false positives), as well as any PUA substitutions. Anything remaining should only be script code "None" | ||