Module:LuaTemplateBlueprint: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 1,089: | Line 1,089: | ||
and centralizes normalization logic for clarity and consistency. | and centralizes normalization logic for clarity and consistency. | ||
]] | ]] | ||
-- Override raw country/region with normalized names | -- Override raw country/region with normalized names if country field exists | ||
local cr = require('Module:ConfigRepository') | if args.country and args.country ~= '' then | ||
local cr = require('Module:ConfigRepository') | |||
local cd = require('Module:CountryData') | |||
local norm = p.protectedExecute( | |||
template, | |||
'CountryData_Override', | |||
function() return cd.getSemanticCountryRegionProperties(args.country) end, | |||
{}, | |||
args.country | |||
) | |||
if norm then | |||
local countryKey = cr.semanticProperties.country | |||
local regionKey = cr.semanticProperties.region | |||
if norm[countryKey] then | |||
collector.properties[countryKey] = norm[countryKey] | |||
end | |||
if norm[regionKey] then | |||
collector.properties[regionKey] = norm[regionKey] | |||
end | |||
end | |||
end | |||
-- Send all deduplicated properties to SemanticAnnotations in one batch | |||
local semanticOutput = SemanticAnnotations.setSemanticProperties( | local semanticOutput = SemanticAnnotations.setSemanticProperties( | ||
args, | args, | ||
collector.properties, | |||
semanticOptions | semanticOptions | ||
) | ) | ||