Module:CountryData: Difference between revisions
// via Wikitext Extension for VSCode Tag: Manual revert |
// via Wikitext Extension for VSCode |
||
| Line 3: | Line 3: | ||
-- | -- | ||
-- Features: | -- Features: | ||
-- * Loads country data from JSON stored in | -- * Loads country data from JSON stored in Data:CountryDataset.json | ||
-- * Normalizes country names to canonical forms | -- * Normalizes country names to canonical forms | ||
-- * Maps countries to ICANN regions | -- * Maps countries to ICANN regions | ||
| Line 172: | Line 172: | ||
if frame and type(frame) == "table" and frame.preprocess then | if frame and type(frame) == "table" and frame.preprocess then | ||
local preprocessSuccess, preprocessResult = pcall(function() | local preprocessSuccess, preprocessResult = pcall(function() | ||
return frame:preprocess('{{ | return frame:preprocess('{{Data:CountryDataset.json}}') | ||
end) | end) | ||
| Line 185: | Line 185: | ||
if mw.loadJsonData then | if mw.loadJsonData then | ||
local loadJsonSuccess, jsonData = pcall(function() | local loadJsonSuccess, jsonData = pcall(function() | ||
return mw.loadJsonData(' | return mw.loadJsonData('Data:CountryDataset.json') | ||
end) | end) | ||
| Line 194: | Line 194: | ||
-- Direct content loading approach as fallback | -- Direct content loading approach as fallback | ||
local pageTitle = mw.title.new(' | local pageTitle = mw.title.new('Data:CountryDataset.json') | ||
if not pageTitle or not pageTitle.exists then | if not pageTitle or not pageTitle.exists then | ||
return DEFAULT_DATA | return DEFAULT_DATA | ||