Automattic / wp-cldr

Use CLDR localization data in WordPress
GNU General Public License v2.0
23 stars 6 forks source link

get_territories_contained does not work for non-numeric groupings #102

Open bluefuton opened 8 months ago

bluefuton commented 8 months ago

get_territories_contained, which lists territories within a region or grouping, makes two assumptions:

The data also contains groupings like 'EU', 'EZ' (Eurozone) which have two letters. This means it's not possible to get a list of EU countries like this:

$locale = 'de';
$cldr = new WP_CLDR( $locale );
$eu_countries = $cldr->get_territories_contained( 'EU' );

It would be useful if get_territories_contained could return this too - perhaps by validating what keys are available in the JSON file instead.

https://github.com/Automattic/wp-cldr/blob/master/data/41.0.0/supplemental/territoryContainment.json