Module:CountryData: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
Line 577: Line 577:
      
      
     local countries = {}
     local countries = {}
     for country in string.gmatch(value, "[^;]+") do
     for countryName in string.gmatch(value, "[^;]+") do
         local trimmed = country:match("^%s*(.-)%s*$")
         local trimmed = countryName:match("^%s*(.-)%s*$")
         if trimmed and trimmed ~= "" then
         if trimmed and trimmed ~= "" then
             table.insert(countries, trimmed)
             local normalized = CountryData.normalizeCountryName(trimmed)
            if normalized ~= "(Unrecognized)" then
                table.insert(countries, normalized)
            end
         end
         end
     end
     end
      
      
     local normalizedCountries = {}
     return countries
    for _, country in ipairs(countries) do
        local normalized = CountryData.normalizeCountryName(country)
        if normalized ~= "(Unrecognized)" then
            table.insert(normalizedCountries, normalized)
        end
    end
   
    return normalizedCountries
end
end