Module:CountryData: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
Line 607: Line 607:
end
end


-- Get semantic property name from ConfigRepository
function CountryData.getSemanticPropertyName(propertyKey)
    local ConfigRepository = require('Module:ConfigRepository')
   
    -- Look through all template configurations
    for templateName, templateConfig in pairs(ConfigRepository.templates) do
        -- Check if this template has semantics configuration
        if templateConfig.semantics and templateConfig.semantics.additionalProperties then
            -- Check if the property key exists in additionalProperties
            if templateConfig.semantics.additionalProperties[propertyKey] then
                return propertyKey
            end
        end
    end
   
    -- If not found, return nil
    return nil
end


-- Get semantic properties for countries and regions
-- Get semantic properties for countries and regions
Line 637: Line 618:
     end
     end
      
      
     -- Get property names from ConfigRepository
     -- Use standard semantic property names directly
     local countryPropertyName = CountryData.getSemanticPropertyName("Has country")
     local countryPropertyName = "Has country"
     local regionPropertyName = CountryData.getSemanticPropertyName("Has ICANN region")
     local regionPropertyName = "Has ICANN region"
   
    -- If property names are not found in ConfigRepository, we can't proceed
    if not countryPropertyName or not regionPropertyName then
        return properties
    end
      
      
     -- Split multi-value country strings
     -- Split multi-value country strings