Skip Menu |

This queue is for tickets about the Locale-Codes CPAN distribution.

Report information
The Basics
Id: 12373
Status: resolved
Priority: 0/
Queue: Locale-Codes

People
Owner: Nobody in particular
Requestors: steve [...] purkis.ca
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.07
Fixed in: (no value)



Subject: Locale::Language: support alias for countries
Hiya, At the moment, Locale::Country supports setting aliases for country _codes_, but does not allow for setting aliases of _countries_. I'd like to alias "UK" and "U.K."--> "Great Britain" / "United Kingdom", so that we can preserve the ISO 3166-1 codes (ie - country2code( 'United Kingdom' ) should still return 'gb'), and so I will get back 'gb' when I call country2code( 'UK' ). For example, in the perl debugger: DB<1> use Locale::Country qw( country2code code2country ) DB<2> x country2code( 'UK' ) 0 undef DB<3> p country2code( 'U.K.' ) 0 undef DB<4> p country2code( 'United Kingdom' ) 0 'gb' DB<5> Locale::Country::alias_code('uk' => 'gb'); DB<6> p country2code( 'United Kingdom' ) 0 'uk' # This should still return 'gb'! Ideally, I'd like to be able to say: Locale::Country::alias_country('UK' => 'United Kingdom'); -Steve
On Thu Apr 21 13:06:50 2005, guest wrote: Show quoted text
> Hiya, > > At the moment, Locale::Country supports setting aliases for country > _codes_, but does not allow for setting aliases of _countries_. > > I'd like to alias "UK" and "U.K."--> "Great Britain" / "United > Kingdom", so that we can preserve the ISO 3166-1 codes (ie - > country2code( 'United Kingdom' ) should still return 'gb'), and so > I will get back 'gb' when I call country2code( 'UK' ). > > For example, in the perl debugger: > > DB<1> use Locale::Country qw( country2code code2country ) > DB<2> x country2code( 'UK' ) > 0 undef > DB<3> p country2code( 'U.K.' ) > 0 undef > DB<4> p country2code( 'United Kingdom' ) > 0 'gb' > > DB<5> Locale::Country::alias_code('uk' => 'gb'); > DB<6> p country2code( 'United Kingdom' ) > 0 'uk' > # This should still return 'gb'! > > Ideally, I'd like to be able to say: > > Locale::Country::alias_country('UK' => 'United Kingdom'); > > -Steve
Me too. In fact, it already supports United States and USA without the need for any user-specified alias, so why not United Kingdom and UK? Indeed, it also supports United States of America, so it should also support United Kingdom of Great Britain and Northern Ireland too. The attached patch does this. I'd still like to see an alias mechanism as well as this, though.
diff -ruN Locale-Codes-2.07.orig/lib/Locale/Country.pm Locale-Codes-2.07/lib/Locale/Country.pm --- Locale-Codes-2.07.orig/lib/Locale/Country.pm 2004-06-10 23:19:34.000000000 +0100 +++ Locale-Codes-2.07/lib/Locale/Country.pm 2009-11-10 13:50:02.986138600 +0000 @@ -383,7 +383,7 @@ fr:fra:250:France fx:fxx:249:France, Metropolitan ga:gab:266:Gabon -gb:gbr:826:United Kingdom:Great Britain +gb:gbr:826:United Kingdom:UK:United Kingdom of Great Britain and Northern Ireland:Great Britain gd:grd:308:Grenada ge:geo:268:Georgia gf:guf:254:French Guiana
I just took over maintenance of Locale-Codes, and this seems like a good suggestion. I'll see about adding it to 3.01. I just wanted to reply to let you know that Locale-Codes is under active maintenance again so hopefully this will be available shortly.
Version 3.10 will have a full set of routines for modifying internal data for all types of code sets.
In addition, I've added the "uk" alias suggested by Steve Hay (the other suggested alias is already present due to it's inclusion in the standards).