Module:CountryData: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 255: | Line 255: | ||
if code and data.countries[code] then | if code and data.countries[code] then | ||
result = data.countries[code] | result = data.countries[code] | ||
else | |||
-- Try with diacritics removed | |||
local stripped = DiacriticNormalization.removeDiacritics(normalized) | |||
if stripped ~= normalized then | |||
code = nameLookup[stripped] | |||
if code and data.countries[code] then | |||
result = data.countries[code] | |||
end | |||
end | |||
end | end | ||
| Line 282: | Line 291: | ||
-- Look up the code | -- Look up the code | ||
local code = nameLookup[normalized] | local code = nameLookup[normalized] | ||
if not code then | |||
-- Try with diacritics removed | |||
local stripped = DiacriticNormalization.removeDiacritics(normalized) | |||
if stripped ~= normalized then | |||
code = nameLookup[stripped] | |||
end | |||
end | |||
-- Cache the result (including nil) | -- Cache the result (including nil) | ||