Module:language-like: Difference between revisions
otherNames -> other_names for consistency Tag: Reverted |
No edit summary Tag: Manual revert |
||
| (One intermediate revision by the same user not shown) | |||
| Line 4: | Line 4: | ||
local table_module = "Module:table" | local table_module = "Module:table" | ||
local wikibase = mw.wikibase | --local wikibase = mw.wikibase | ||
local category_name_has_suffix -- defined as export.categoryNameHasSuffix below | local category_name_has_suffix -- defined as export.categoryNameHasSuffix below | ||
local get_entity = wikibase.getEntity | --local get_entity = wikibase.getEntity | ||
local get_entity_id_for_title = wikibase.getEntityIdForTitle | --local get_entity_id_for_title = wikibase.getEntityIdForTitle | ||
local gsub = string.gsub | local gsub = string.gsub | ||
local ipairs = ipairs | local ipairs = ipairs | ||
local match = string.match | local match = string.match | ||
local select = select | local select = select | ||
local sitelink = wikibase.sitelink | --local sitelink = wikibase.sitelink | ||
local type = type | local type = type | ||
local umatch = mw.ustring.match | local umatch = mw.ustring.match | ||
| Line 71: | Line 71: | ||
-- families, scripts and writing systems. | -- families, scripts and writing systems. | ||
function export.getOtherNames(self) | function export.getOtherNames(self) | ||
local other_names = self. | local other_names = self._otherNames | ||
if other_names == nil then | if other_names == nil then | ||
other_names = (self._data or self). | other_names = (self._data or self).otherNames or {} | ||
self. | self._otherNames = other_names | ||
end | end | ||
return other_names | return other_names | ||
| Line 190: | Line 190: | ||
-- Otherwise, check the Wikidata item for a sitelink. | -- Otherwise, check the Wikidata item for a sitelink. | ||
local item = self:getWikidataItem() | local item = self:getWikidataItem() | ||
article = item and sitelink(item, project) or false | article = self:getCanonicalName() or false --item and sitelink(item, project) or false | ||
if article then | if article then | ||
return article | return article | ||
| Line 256: | Line 256: | ||
local function get_commons_cat_sitelink(item) | local function get_commons_cat_sitelink(item) | ||
if item then | --[[if item then | ||
local commons_sitelink = sitelink(item, "commonswiki") | local commons_sitelink = sitelink(item, "commonswiki") | ||
-- Reject any sitelinks that aren't categories. | -- Reject any sitelinks that aren't categories. | ||
return commons_sitelink and match(commons_sitelink, "^Category:") and commons_sitelink or nil | return commons_sitelink and match(commons_sitelink, "^Category:") and commons_sitelink or nil | ||
end | end]] | ||
return nil | |||
end | end | ||