| Server IP : 170.10.162.208 / Your IP : 216.73.216.181 Web Server : LiteSpeed System : Linux altar19.supremepanel19.com 4.18.0-553.69.1.lve.el8.x86_64 #1 SMP Wed Aug 13 19:53:59 UTC 2025 x86_64 User : deltahospital ( 1806) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/deltahospital/.cagefs/tmp/ |
Upload File : |
Maketext/Simple.pm 0000644 00000023100 15051125755 0010117 0 ustar 00 package Locale::Maketext::Simple;
$Locale::Maketext::Simple::VERSION = '0.21_01';
use strict;
use 5.005;
=head1 NAME
Locale::Maketext::Simple - Simple interface to Locale::Maketext::Lexicon
=head1 VERSION
This document describes version 0.18 of Locale::Maketext::Simple,
released Septermber 8, 2006.
=head1 SYNOPSIS
Minimal setup (looks for F<auto/Foo/*.po> and F<auto/Foo/*.mo>):
package Foo;
use Locale::Maketext::Simple; # exports 'loc'
loc_lang('fr'); # set language to French
sub hello {
print loc("Hello, [_1]!", "World");
}
More sophisticated example:
package Foo::Bar;
use Locale::Maketext::Simple (
Class => 'Foo', # search in auto/Foo/
Style => 'gettext', # %1 instead of [_1]
Export => 'maketext', # maketext() instead of loc()
Subclass => 'L10N', # Foo::L10N instead of Foo::I18N
Decode => 1, # decode entries to unicode-strings
Encoding => 'locale', # but encode lexicons in current locale
# (needs Locale::Maketext::Lexicon 0.36)
);
sub japh {
print maketext("Just another %1 hacker", "Perl");
}
=head1 DESCRIPTION
This module is a simple wrapper around B<Locale::Maketext::Lexicon>,
designed to alleviate the need of creating I<Language Classes> for
module authors.
The language used is chosen from the loc_lang call. If a lookup is not
possible, the i-default language will be used. If the lookup is not in the
i-default language, then the key will be returned.
If B<Locale::Maketext::Lexicon> is not present, it implements a
minimal localization function by simply interpolating C<[_1]> with
the first argument, C<[_2]> with the second, etc. Interpolated
function like C<[quant,_1]> are treated as C<[_1]>, with the sole
exception of C<[tense,_1,X]>, which will append C<ing> to C<_1> when
X is C<present>, or appending C<ed> to <_1> otherwise.
=head1 OPTIONS
All options are passed either via the C<use> statement, or via an
explicit C<import>.
=head2 Class
By default, B<Locale::Maketext::Simple> draws its source from the
calling package's F<auto/> directory; you can override this behaviour
by explicitly specifying another package as C<Class>.
=head2 Path
If your PO and MO files are under a path elsewhere than C<auto/>,
you may specify it using the C<Path> option.
=head2 Style
By default, this module uses the C<maketext> style of C<[_1]> and
C<[quant,_1]> for interpolation. Alternatively, you can specify the
C<gettext> style, which uses C<%1> and C<%quant(%1)> for interpolation.
This option is case-insensitive.
=head2 Export
By default, this module exports a single function, C<loc>, into its
caller's namespace. You can set it to another name, or set it to
an empty string to disable exporting.
=head2 Subclass
By default, this module creates an C<::I18N> subclass under the
caller's package (or the package specified by C<Class>), and stores
lexicon data in its subclasses. You can assign a name other than
C<I18N> via this option.
=head2 Decode
If set to a true value, source entries will be converted into
utf8-strings (available in Perl 5.6.1 or later). This feature
needs the B<Encode> or B<Encode::compat> module.
=head2 Encoding
Specifies an encoding to store lexicon entries, instead of
utf8-strings. If set to C<locale>, the encoding from the current
locale setting is used. Implies a true value for C<Decode>.
=cut
sub import {
my ($class, %args) = @_;
$args{Class} ||= caller;
$args{Style} ||= 'maketext';
$args{Export} ||= 'loc';
$args{Subclass} ||= 'I18N';
my ($loc, $loc_lang) = $class->load_loc(%args);
$loc ||= $class->default_loc(%args);
no strict 'refs';
*{caller(0) . "::$args{Export}"} = $loc if $args{Export};
*{caller(0) . "::$args{Export}_lang"} = $loc_lang || sub { 1 };
}
my %Loc;
sub reload_loc { %Loc = () }
sub load_loc {
my ($class, %args) = @_;
my $pkg = join('::', grep { defined and length } $args{Class}, $args{Subclass});
return $Loc{$pkg} if exists $Loc{$pkg};
eval {
local @INC = @INC;
pop @INC if $INC[-1] eq '.';
require Locale::Maketext::Lexicon;
1
} or return;
$Locale::Maketext::Lexicon::VERSION > 0.20 or return;
eval { require File::Spec; 1 } or return;
my $path = $args{Path} || $class->auto_path($args{Class}) or return;
my $pattern = File::Spec->catfile($path, '*.[pm]o');
my $decode = $args{Decode} || 0;
my $encoding = $args{Encoding} || undef;
$decode = 1 if $encoding;
$pattern =~ s{\\}{/}g; # to counter win32 paths
eval "
package $pkg;
use base 'Locale::Maketext';
Locale::Maketext::Lexicon->import({
'i-default' => [ 'Auto' ],
'*' => [ Gettext => \$pattern ],
_decode => \$decode,
_encoding => \$encoding,
});
*${pkg}::Lexicon = \\%${pkg}::i_default::Lexicon;
*tense = sub { \$_[1] . ((\$_[2] eq 'present') ? 'ing' : 'ed') }
unless defined &tense;
1;
" or die $@;
my $lh = eval { $pkg->get_handle } or return;
my $style = lc($args{Style});
if ($style eq 'maketext') {
$Loc{$pkg} = sub {
$lh->maketext(@_)
};
}
elsif ($style eq 'gettext') {
$Loc{$pkg} = sub {
my $str = shift;
$str =~ s{([\~\[\]])}{~$1}g;
$str =~ s{
([%\\]%) # 1 - escaped sequence
|
% (?:
([A-Za-z#*]\w*) # 2 - function call
\(([^\)]*)\) # 3 - arguments
|
([1-9]\d*|\*) # 4 - variable
)
}{
$1 ? $1
: $2 ? "\[$2,"._unescape($3)."]"
: "[_$4]"
}egx;
return $lh->maketext($str, @_);
};
}
else {
die "Unknown Style: $style";
}
return $Loc{$pkg}, sub {
$lh = $pkg->get_handle(@_);
};
}
sub default_loc {
my ($self, %args) = @_;
my $style = lc($args{Style});
if ($style eq 'maketext') {
return sub {
my $str = shift;
$str =~ s{((?<!~)(?:~~)*)\[_([1-9]\d*|\*)\]}
{$1%$2}g;
$str =~ s{((?<!~)(?:~~)*)\[([A-Za-z#*]\w*),([^\]]+)\]}
{"$1%$2(" . _escape($3) . ')'}eg;
_default_gettext($str, @_);
};
}
elsif ($style eq 'gettext') {
return \&_default_gettext;
}
else {
die "Unknown Style: $style";
}
}
sub _default_gettext {
my $str = shift;
$str =~ s{
% # leading symbol
(?: # either one of
\d+ # a digit, like %1
| # or
(\w+)\( # a function call -- 1
(?: # either
%\d+ # an interpolation
| # or
([^,]*) # some string -- 2
) # end either
(?: # maybe followed
, # by a comma
([^),]*) # and a param -- 3
)? # end maybe
(?: # maybe followed
, # by another comma
([^),]*) # and a param -- 4
)? # end maybe
[^)]* # and other ignorable params
\) # closing function call
) # closing either one of
}{
my $digit = $2 || shift;
$digit . (
$1 ? (
($1 eq 'tense') ? (($3 eq 'present') ? 'ing' : 'ed') :
($1 eq 'quant') ? ' ' . (($digit > 1) ? ($4 || "$3s") : $3) :
''
) : ''
);
}egx;
return $str;
};
sub _escape {
my $text = shift;
$text =~ s/\b_([1-9]\d*)/%$1/g;
return $text;
}
sub _unescape {
join(',', map {
/\A(\s*)%([1-9]\d*|\*)(\s*)\z/ ? "$1_$2$3" : $_
} split(/,/, $_[0]));
}
sub auto_path {
my ($self, $calldir) = @_;
$calldir =~ s#::#/#g;
my $path = $INC{$calldir . '.pm'} or return;
# Try absolute path name.
if ($^O eq 'MacOS') {
(my $malldir = $calldir) =~ tr#/#:#;
$path =~ s#^(.*)$malldir\.pm\z#$1auto:$malldir:#s;
} else {
$path =~ s#^(.*)$calldir\.pm\z#$1auto/$calldir/#;
}
return $path if -d $path;
# If that failed, try relative path with normal @INC searching.
$path = "auto/$calldir/";
foreach my $inc (@INC) {
return "$inc/$path" if -d "$inc/$path";
}
return;
}
1;
=head1 ACKNOWLEDGMENTS
Thanks to Jos I. Boumans for suggesting this module to be written.
Thanks to Chia-Liang Kao for suggesting C<Path> and C<loc_lang>.
=head1 SEE ALSO
L<Locale::Maketext>, L<Locale::Maketext::Lexicon>
=head1 AUTHORS
Audrey Tang E<lt>cpan@audreyt.orgE<gt>
=head1 COPYRIGHT
Copyright 2003, 2004, 2005, 2006 by Audrey Tang E<lt>cpan@audreyt.orgE<gt>.
This software is released under the MIT license cited below. Additionally,
when this software is distributed with B<Perl Kit, Version 5>, you may also
redistribute it and/or modify it under the same terms as Perl itself.
=head2 The "MIT" License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
=cut
Codes.pod 0000644 00000047676 15051136664 0006340 0 ustar 00 =pod
=head1 NAME
Locale::Codes - a distribution of modules to handle locale codes
=head1 DESCRIPTION
B<Locale-Codes> is a distribution containing a set of modules designed
to work with sets of codes which uniquely identify something. For
example, there are codes associated with different countries, different
currencies, different languages, etc. These sets of codes are typically
maintained in some standard.
This distribution provides a way to work with these lists of codes.
Because the data from the various standards is not available in any
sort of consistent API, access to the lists is not available in any
direct fashion. To compensate for this, the list of codes is stored
internally within this distribution, and the distribution is updated
on a regular basis to include all known codes at that point in time.
This does mean that it is necessary to keep this distribution
up-to-date to keep up with the various changes that are made in the
various standards.
Traditionally, a module has been created to work with each type of
code sets. So, there is a module for working with country lists, one
for currency lists, etc. Since version 3.00, all of these individual
modules were written as wrappers around a central module (which was not
intended to be used directly) which did all of the real work.
Starting with version 3.50, the central module was reworked slightly
to provide an object-oriented interface. All of the modules for
working with individual types of code sets were reworked to use the
improved OO module, so the traditional interfaces still work as they
always have. As a result, you are free to use the traditional
functional (non-OO) interfaces, or to use the OO interface and bypass
the wrapper modules entirely.
Both methods will be supported in the future, so use the one that is
best suited to your needs.
Within each type, any number of code sets are allowed. For example,
sets of country codes are maintained in several different locations
including the ISO-3166 standard, the IANA, and by the United Nations.
The lists of countries are similar, but not identical. Multiple code
sets are supported, though trying to convert from one code set to
another will not always work since the list of countries is not
one-to-one.
All data in all of these modules comes directly from the original
standards (or as close to direct as possible), so it should be
up-to-date at the time of release.
I plan on releasing a new version several times a year to incorporate
any changes made in the standards. However, I don't always know about
changes that occur, so if any of the standards change, and you want a
new release sooner, just email me and I'll get one out.
=head1 SYNOPSIS (OBJECT-ORIENTED INTERFACE)
use Locale::Codes;
or
use Locale::Codes ':constants';
$obj = new Locale::Codes 'country';
=head1 OBJECT-ORIENTED METHODS
The following methods are available.
In all methods, when specifying a code set, the name (as a string)
is always available.
Traditionally, you could also use a perl constant to specify the
code set. In order to do so with the OO interface, you have to
import the constants. To do that, load the module with:
use Locale::Codes ':constants';
=over 4
=item B<new ( [TYPE [,CODESET]] )>
$obj = new Locale::Codes;
$obj = new Locale::Codes 'country';
$obj = new Locale::Codes 'country','alpha-3';
$obj = new Locale::Codes 'country',LOCALE_COUNTRY_ALPHA_3;
This creates a new object that can access the data. If no type is specified
(in the first argument), you must use the B<type> method described below.
No operations will work unless the type is specified.
The second argument is the default code set to use. This is optional, as
each type has a default code set. The default code set can be set using
the B<codeset> method below.
The last example is only available if the constants were imported when
the module was loaded.
=item B<show_errors ( FLAG )>
$obj->show_errors(1);
$obj->show_errors(0);
By default, error messages will be produced when bad data is passed
to any method. By passing in '0', these will be turned off so that
all failures will be silent.
=item B<type ( TYPE )>
$obj->type($type)
This will set the type of codes that will be worked with. C<$type> may
be any of the recognized types of code sets, including:
country
language
currency
script
etc.
The list of valid types, and the code sets supported in each, are described
in the L<Locale::Codes::Types> document.
This method can be called any number of times to toggle between different types
of code sets.
=item B<codeset ( CODESET )>
$obj->codeset($codeset);
This sets the default code set to use. The list of code sets available
for each type are described in the L<Locale::Codes::Types> document.
In all other methods below, when an optional B<CODESET> argument is
omitted, it will default to this value.
=item B<code2name ( CODE [,CODESET] [,'retired'] )>
$name = $obj->code2name($code [,$codeset] [,'retired']);
This functions take a code and returns a string which contains
the name of the element identified. If the code is not a valid
code in the B<CODESET> specified then C<undef> will be returned.
The name of the element is the name as specified in the standard,
and as a result, different variations of an element name may
be returned for different values of B<CODESET>.
For example, the alpha-2 country code set defines the two-letter
code "bo" to be "Bolivia, Plurinational State of", whereas the
alpha-3 code set defines the code 'bol' to be the country "Bolivia
(Plurinational State of)". So:
$obj->code2name('bo','alpha-2');
=> 'Bolivia, Plurinational State of'
$obj->code2name('bol','alpha-3');
=> 'Bolivia (Plurinational State of)'
By default, only active codes will be used, but if the string
'retired' is passed in as an argument, both active and retired
codes will be examined.
=item B<name2code ( NAME [,CODESET] [,'retired'] )>
$code = $obj->name2code($name [,$codeset] [,'retired']);
This function takes the name of an element (or any of it's aliases)
and returns the code that corresponds to it, if it exists. If B<NAME>
could not be identified as the name of one of the elements, then
C<undef> will be returned.
The name is not case sensitive. Also, any known variation of a name
may be passed in.
For example, even though the country name returned using 'alpha-2'
and 'alpha-3' country codes for Bolivia are different, either country
name may be passed in since for each code set (in addition to the more
common alias 'Bolivia'). So:
$obj->name2code('Bolivia, Plurinational State of','alpha-2');
=> bo
$obj->name2code('Bolivia (Plurinational State of)','alpha-2');
=> bo
$obj->name2code('Bolivia','alpha-2');
=> bo
By default, only active names will be used, but if the string
'retired' is passed in as an argument, both active and retired
names will be examined.
=item B<code2code ( CODE [,CODESET] ,CODESET2 )>
$code = $obj->code2code($code [,$codeset] ,$codeset2);
This function takes a code from one code set (B<CODESET> or the
default code set), and returns the corresponding code from another
code set (B<CODESET2>). B<CODE> must exists in the code set specified
by B<CODESET> and must have a corresponding code in the
code set specified by B<CODESET2> or C<undef> will be returned.
$obj->code2code('fin','alpha-3','alpha-2');
=> 'fi'
Note that this function does NOT support retired codes.
=item B<all_codes ( [CODESET] [,'retired'] )>
@code = $obj->all_codes([$codeset] [,'retired']);
This returns a list of all code in the code set. The codes will be
sorted.
By default, only active codes will be returned, but if the string
'retired' is passed in as an argument, both active and retired
codes will be returned.
=item B<all_names ( [CODESET] [,'retired'] )>
@name = $obj->all_names([$codeset] [,'retired']);
This method returns a list of all elements names for which there is a
corresponding code in the specified code set.
The names returned are exactly as they are specified in the standard,
and are sorted.
Since not all elements are listed in all code sets, the list of
elements may differ depending on the code set specified.
By default, only active names will be returned, but if the string
'retired' is passed in as an argument, both active and retired
names will be returned.
=back
The following additional methods are available and can be used to
modify the code list data (and are therefore not generally useful).
=over 4
=item B<rename_code ( CODE ,NEW_NAME [,CODESET] )>
$flag = $obj->rename_code($code,$new_name [,$codeset]);
This method can be used to change the official name of an element. At
that point, the name returned by the C<code2name> method would be
B<NEW_NAME> instead of the name specified in the standard.
The original name will remain as an alias.
For example, the official country name for code 'gb' is 'United
Kingdom'. If you want to change that, you might call:
$obj->rename_code('gb', 'Great Britain');
This means that calling code2name('gb') will now return 'Great
Britain' instead of 'United Kingdom'.
If any error occurs, a warning is issued and 0 is returned. An error
occurs if B<CODE> doesn't exist in the specified code set, or if
B<NEW_NAME> is already in use but for a different element.
If the method succeeds, 1 is returned.
=item B<add_code ( CODE ,NAME [,CODESET] )>
$flag = $obj->add_code($code,$name [,$codeset]);
This method is used to add a new code and name to the data.
Both B<CODE> and B<NAME> must be unused in the data set or an error
occurs (though B<NAME> may be used in a different data set).
For example, to create the fictitious country named "Duchy of
Grand Fenwick" with codes "gf" and "fen", use the following:
$obj->add_code("fe","Duchy of Grand Fenwick",'alpha-2');
$obj->add_code("fen","Duchy of Grand Fenwick",'alpha-3');
The return value is 1 on success, 0 on an error.
=item B<delete_code ( CODE [,CODESET] )>
$flag = $obj->delete_code($code [,$codeset]);
This method is used to delete a code from the data.
B<CODE> must refer to an existing code in the code set.
The return value is 1 on success, 0 on an error.
=item B<add_alias ( NAME ,NEW_NAME )>
$flag = $obj->add_alias($name,$new_name);
This method is used to add a new alias to the data. They do
not alter the return value of the C<code2name> function.
B<NAME> must be an existing element name, and B<NEW_NAME> must
be unused or an error occurs.
The return value is 1 on success, 0 on an error.
=item B<delete_alias ( NAME )>
$flag = $obj->delete_alias($name);
This method is used to delete an alias from the data. Once
removed, the element may not be referred to by B<NAME>.
B<NAME> must be one of a list of at least two names that may be used to
specify an element. If the element may only be referred to by a single
name, you'll need to use the C<add_alias> method to add a new alias
first, or the C<remove_code> method to remove the element entirely.
If the alias is used as the name in any code set, one of the other
names will be used instead. Predicting exactly which one will
be used requires you to know the order in which the standards
were read, which is not reliable, so you may want to use the
C<rename_code> method to force one of the alternate names to be
used.
The return value is 1 on success, 0 on an error.
=item B<replace_code ( CODE ,NEW_CODE [,CODESET] )>
$flag = $obj->replace_code($code,$new_code [,$codeset]);
This method is used to change the official code for an element. At
that point, the code returned by the C<name2code> method would be
B<NEW_CODE> instead of the code specified in the standard.
B<NEW_CODE> may either be a code that is not in use, or it may be an
alias for B<CODE> (in which case, B<CODE> becomes and alias and B<NEW_CODE>
becomes the "real" code).
The original code is kept as an alias, so that the C<code2name> routines
will work with either the code from the standard or the new code.
However, the C<all_codes> method will only return the codes which
are considered "real" (which means that the list of codes will now
contain B<NEW_CODE>, but will not contain B<CODE>).
=item B<add_code_alias ( CODE ,NEW_CODE [,CODESET] )>
$flag = $obj->add_code_alias($code,$new_code [,$codeset]);
This method adds an alias for the code. At that point, B<NEW_CODE> and B<CODE>
will both work in the C<code2name> method. However, the C<name2code> method will
still return the original code.
=item B<delete_code_alias ( CODE [,CODESET] )>
These routines delete an alias for the code.
These will only work if B<CODE> is actually an alias. If it is the "real"
code, it will not be deleted. You will need to use the C<rename_code>
method to switch the real code with one of the aliases, and then
delete the alias.
=back
=head1 TRADITIONAL INTERFACES
In addition the the primary OO module, the following modules are included in
the distribution for the traditional way of working with code sets.
Each module will work with one specific type of code sets.
=over 4
=item L<Locale::Codes::Country>, L<Locale::Country>
This includes support for country codes (such as those listed in ISO-3166)
to specify the country.
Because this module was originally distributed as L<Locale::Country>, it is
also available under that name.
=item L<Locale::Codes::Language>, L<Locale::Language>
This includes support for language codes (such as those listed in ISO-639)
to specify the language.
Because this module was originally distributed as L<Locale::Language>, it is
also available under that name.
=item L<Locale::Codes::Currency>, L<Locale::Currency>
This includes support for currency codes (such as those listed in ISO-4217)
to specify the currency.
Because this module was originally distributed as L<Locale::Currency>, it is
also available under that name.
=item L<Locale::Codes::Script>, L<Locale::Script>
This includes support for script codes (such as those listed in ISO-15924)
to specify the script.
Because this module was originally distributed as L<Locale::Script>, it is
also available under that name.
=item L<Locale::Codes::LangExt>
This includes support for language extension codes (such as those listed
in the IANA language registry) to specify the language extension.
=item L<Locale::Codes::LangVar>
This includes support for language variation codes (such as those listed
in the IANA language registry) to specify the language variation.
=item L<Locale::Codes::LangFam>
This includes support for language family codes (such as those listed
in ISO 639-5) to specify families of languages.
=back
In addition to the modules above, there are a number of support modules included
in the distribution. Any module not listed above falls into that category.
These modules are not intended to be used by programmers. They contain functions
or data that are used by the modules listed above. No support of any kind is
offered for using these modules directly. They may be modified at any time.
=head1 COMMON ALIASES
As of version 2.00, the modules supported common variants of names.
For example, Locale::Country supports variant names for countries, and
a few of the most common ones are included in the data. The country
code for "United States" is "us", so:
country2code('United States');
=> "us"
Now the following will also return 'us':
country2code('United States of America');
country2code('USA');
Any number of common aliases may be included in the data, in addition
to the names that come directly from the standards. If you have a
common alias for a country, language, or any other of the types of
codes, let me know and I'll add it, with some restrictions.
For example, the country name "North Korea" never appeared in any of
the official sources (instead, it was "Korea, North" or "Korea,
Democratic People's Republic of". I would honor a request to add an
alias "North Korea" since that's a very common way to specify the
country (please don't request this... I've already added it).
On the other hand, a request to add Zaire as an alias for "Congo, The
Democratic Republic of" will not be honored. The country's official
name is no longer Zaire, so adding it as an alias violates the
standard. Zaire was kept as an alias in versions of this module prior
to 3.00, but it has been removed. Other aliases (if any) which no
longer appear in any standard (and which are not common variations of
the name in the standards) have also been removed.
=head1 RETIRED CODES
Occasionally, a code is deprecated, but it may still be desirable to
have access to it.
Although there is no way to see every code that has ever existed and
been deprecated (since most codesets do not have that information
available), as of version 3.20, every code which has ever been included
in these modules can be referenced.
For more information, refer to the documentation on the code2name, name2code,
all_codes, and all_names methods above.
=head1 SEE ALSO
=over 4
=item L<Locale::Codes::Types>
The list of all code sets available for each type.
=item L<Locale::Codes::Changes>
A history of changes made to this distribution.
=back
=head1 KNOWN BUGS AND LIMITATIONS
=over 4
=item B<Relationship between code sets>
Because each code set uses a slightly different list of elements, and
they are not necessarily one-to-one, there may be some confusion
about the relationship between codes from different code sets.
For example, ISO 3166 assigns one code to the country "United States
Minor Outlying Islands", but the IANA codes give different codes
to different islands (Baker Island, Howland Island, etc.).
This may cause some confusion... I've done the best that I could do
to minimize it.
=item B<Non-ASCII characters not supported>
Currently all names must be all ASCII. I plan on relaxing that
limitation in the future.
=back
=head1 BUGS AND QUESTIONS
If you find a bug in Locale::Codes, there are three ways to send it to me.
Any of them are fine, so use the method that is easiest for you.
=over 4
=item Direct email
You are welcome to send it directly to me by email. The email address
to use is: sbeck@cpan.org.
=item CPAN Bug Tracking
You can submit it using the CPAN tracking too. This can be done at the
following URL:
L<http://rt.cpan.org/Public/Dist/Display.html?Name=Locale-Codes>
=item GitHub
You can submit it as an issue on GitHub. This can be done at the following
URL:
L<https://github.com/SBECK-github/Locale-Codes>
=back
Please do not use other means to report bugs (such as forums for a specific
OS or Linux distribution) as it is impossible for me to keep up with all of
them.
When filing a bug report, please include the following information:
=over 4
=item B<Locale::Codes version>
Please include the version of Locale::Codes you are using. You can get
this by using the script:
use Locale::Codes;
print $Locale::Codes::VERSION,"\n";
=back
If you want to report missing or incorrect codes, you must be running the
most recent version of Locale::Codes.
If you find any problems with the documentation (errors, typos, or items
that are not clear), please send them to me. I welcome any suggestions
that will allow me to improve the documentation.
=head1 AUTHOR
Locale::Country and Locale::Language were originally written by Neil
Bowers at the Canon Research Centre Europe (CRE). They maintained the
distribution from 1997 to 2001.
Locale::Currency was originally written by Michael Hennecke and was
modified by Neil Bowers for inclusion in the distribution.
From 2001 to 2004, maintenance was continued by Neil Bowers. He
modified Locale::Currency for inclusion in the distribution. He also
added Locale::Script.
From 2004-2009, the module was unmaintained.
In 2010, maintenance was taken over by Sullivan Beck (sbeck@cpan.org)
with Neil Bower's permission. All problems or comments should be
sent to him using any of the methods listed above.
=head1 COPYRIGHT
Copyright (c) 1997-2001 Canon Research Centre Europe (CRE).
Copyright (c) 2001 Michael Hennecke (Locale::Currency)
Copyright (c) 2001-2010 Neil Bowers
Copyright (c) 2010-2018 Sullivan Beck
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
=cut
Codes.pm 0000644 00000060104 15051136664 0006147 0 ustar 00 package Locale::Codes;
# Copyright (C) 2001 Canon Research Centre Europe (CRE).
# Copyright (C) 2002-2009 Neil Bowers
# Copyright (c) 2010-2018 Sullivan Beck
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
###############################################################################
use strict;
use warnings;
require 5.006;
use Carp;
use if $] >= 5.027007, 'deprecate';
use Locale::Codes::Constants;
our($VERSION);
$VERSION='3.57';
use Exporter qw(import);
our(@EXPORT_OK,%EXPORT_TAGS);
@EXPORT_OK = @Locale::Codes::Constants::CONSTANTS;
%EXPORT_TAGS = ( 'constants' => [ @EXPORT_OK ] );
###############################################################################
# GLOBAL DATA
###############################################################################
# All of the data is stored in a couple global variables. They are filled
# in by requiring the appropriate TYPE_Codes and TYPE_Retired modules.
our(%Data,%Retired);
# $Data{ TYPE }{ code2id }{ CODESET } { CODE } = [ ID, I ]
# { id2code }{ CODESET } { ID } = CODE
# { id2names }{ ID } = [ NAME, NAME, ... ]
# { alias2id }{ NAME } = [ ID, I ]
# { id } = FIRST_UNUSED_ID
# { codealias }{ CODESET } { ALIAS } = CODE
#
# $Retired{ TYPE }{ CODESET }{ code }{ CODE } = NAME
# { name }{ NAME } = [CODE,NAME] (the key is lowercase)
###############################################################################
# METHODS
###############################################################################
sub new {
my($class,$type,$codeset,$show_errors) = @_;
my $self = { 'type' => '',
'codeset' => '',
'err' => (defined($show_errors) ? $show_errors : 1),
};
bless $self,$class;
$self->type($type) if ($type);
$self->codeset($codeset) if ($codeset);
return $self;
}
sub show_errors {
my($self,$val) = @_;
$$self{'err'} = $val;
}
sub type {
my($self,$type) = @_;
if (! exists $ALL_CODESETS{$type}) {
# uncoverable branch false
carp "ERROR: type: invalid argument: $type\n" if ($$self{'err'});
return;
}
# uncoverable branch false
if (! $ALL_CODESETS{$type}{'loaded'}) {
my $label = $ALL_CODESETS{$type}{'module'};
eval "require Locale::Codes::${label}_Codes";
# uncoverable branch true
if ($@) {
# uncoverable statement
croak "ERROR: type: unable to load module: ${label}_Codes\n";
}
eval "require Locale::Codes::${label}_Retired";
# uncoverable branch true
if ($@) {
# uncoverable statement
croak "ERROR: type: unable to load module: ${label}_Retired\n";
}
$ALL_CODESETS{$type}{'loaded'} = 1;
}
$$self{'type'} = $type;
$$self{'codeset'} = $ALL_CODESETS{$type}{'default'};
}
sub codeset {
my($self,$codeset) = @_;
my $type = $$self{'type'};
if (! exists $ALL_CODESETS{$type}{'codesets'}{$codeset}) {
# uncoverable branch false
carp "ERROR: codeset: invalid argument: $codeset\n" if ($$self{'err'});
}
$$self{'codeset'} = $codeset;
}
sub version {
# uncoverable subroutine
# uncoverable statement
my($self) = @_;
# uncoverable statement
return $VERSION;
}
###############################################################################
# This is used to validate a codeset and/or code. It will also format
# a code for that codeset.
#
# (ERR,RET_CODE,RET_CODESET) = $o->_code([CODE [,CODESET]])
#
# If CODE is empty/undef, only the codeset will be validated
# and RET_CODE will be empty.
#
# If CODE is passed in, it will be returned formatted correctly
# for the codeset.
#
# ERR will be 0 or 1.
#
# If $no_check_code is 1, then the code will not be validated (i.e.
# it doesn't already have to exist). This will be useful for adding
# a new code.
#
sub _code {
my($self,$code,$codeset,$no_check_code) = @_;
$code = '' if (! defined($code));
$codeset = lc($codeset) if (defined($codeset));
# uncoverable branch true
if (! $$self{'type'}) {
# uncoverable statement
carp "ERROR: no type set for Locale::Codes object\n" if ($$self{'err'});
# uncoverable statement
return (1);
}
my $type = $$self{'type'};
if ($codeset && ! exists $ALL_CODESETS{$type}{'codesets'}{$codeset}) {
carp "ERROR: _code: invalid codeset provided: $codeset\n"
if ($$self{'err'});
return (1);
}
# If no codeset was passed in, return the codeset specified.
$codeset = $$self{'codeset'} if (! defined($codeset) || $codeset eq '');
return (0,'',$codeset) if ($code eq '');
# Determine the properties of the codeset
my($op,@args) = @{ $ALL_CODESETS{$type}{'codesets'}{$codeset} };
if ($op eq 'lc') {
$code = lc($code);
}
if ($op eq 'uc') {
$code = uc($code);
}
if ($op eq 'ucfirst') {
$code = ucfirst(lc($code));
}
# uncoverable branch false
if ($op eq 'numeric') {
if ($code =~ /^\d+$/) {
my $l = $args[0];
$code = sprintf("%.${l}d", $code);
} else {
# uncoverable statement
carp "ERROR: _code: invalid numeric code: $code\n" if ($$self{'err'});
# uncoverable statement
return (1);
}
}
# Determine if the code is in the codeset.
if (! $no_check_code &&
! exists $Data{$type}{'code2id'}{$codeset}{$code} &&
! exists $Retired{$type}{$codeset}{'code'}{$code} &&
! exists $Data{$type}{'codealias'}{$codeset}{$code}) {
carp "ERROR: _code: code not in codeset: $code [$codeset]\n"
if ($$self{'err'});
return (1);
}
return (0,$code,$codeset);
}
###############################################################################
# $name = $o->code2name(CODE [,CODESET] [,'retired'])
# $code = $o->name2code(NAME [,CODESET] [,'retired'])
#
# Returns the name associated with the CODE (or vice versa).
#
sub code2name {
my($self,@args) = @_;
my $retired = 0;
if (@args && defined($args[$#args]) && lc($args[$#args]) eq 'retired') {
pop(@args);
$retired = 1;
}
# uncoverable branch true
if (! $$self{'type'}) {
# uncoverable statement
carp "ERROR: no type set for Locale::Codes object\n" if ($$self{'err'});
# uncoverable statement
return (1);
}
my $type = $$self{'type'};
my ($err,$code,$codeset) = $self->_code(@args);
return undef if ($err || ! $code);
$code = $Data{$type}{'codealias'}{$codeset}{$code}
if (exists $Data{$type}{'codealias'}{$codeset}{$code});
if (exists $Data{$type}{'code2id'}{$codeset}{$code}) {
my ($id,$i) = @{ $Data{$type}{'code2id'}{$codeset}{$code} };
my $name = $Data{$type}{'id2names'}{$id}[$i];
return $name;
} elsif ($retired && exists $Retired{$type}{$codeset}{'code'}{$code}) {
return $Retired{$type}{$codeset}{'code'}{$code};
} else {
return undef;
}
}
sub name2code {
my($self,$name,@args) = @_;
return undef if (! $name);
$name = lc($name);
my $retired = 0;
if (@args && defined($args[$#args]) && lc($args[$#args]) eq 'retired') {
pop(@args);
$retired = 1;
}
# uncoverable branch true
if (! $$self{'type'}) {
# uncoverable statement
carp "ERROR: no type set for Locale::Codes object\n" if ($$self{'err'});
# uncoverable statement
return (1);
}
my $type = $$self{'type'};
my ($err,$tmp,$codeset) = $self->_code('',@args);
return undef if ($err);
if (exists $Data{$type}{'alias2id'}{$name}) {
my $id = $Data{$type}{'alias2id'}{$name}[0];
if (exists $Data{$type}{'id2code'}{$codeset}{$id}) {
return $Data{$type}{'id2code'}{$codeset}{$id};
}
} elsif ($retired && exists $Retired{$type}{$codeset}{'name'}{$name}) {
return $Retired{$type}{$codeset}{'name'}{$name}[0];
}
return undef;
}
# $code = $o->code2code(CODE,CODESET2)
# $code = $o->code2code(CODE,CODESET1,CODESET2)
#
# Changes the code in the CODESET1 (or the current codeset) to another
# codeset (CODESET2)
#
sub code2code {
my($self,@args) = @_;
# uncoverable branch true
if (! $$self{'type'}) {
# uncoverable statement
carp "ERROR: no type set for Locale::Codes object\n" if ($$self{'err'});
# uncoverable statement
return (1);
}
my $type = $$self{'type'};
my($code,$codeset1,$codeset2,$err);
if (@args == 2) {
($code,$codeset2) = @args;
($err,$code,$codeset1) = $self->_code($code);
# uncoverable branch true
return undef if ($err);
} elsif (@args == 3) {
($code,$codeset1,$codeset2) = @args;
($err,$code) = $self->_code($code,$codeset1);
return undef if ($err);
($err) = $self->_code('',$codeset2);
# uncoverable branch true
return undef if ($err);
}
my $name = $self->code2name($code,$codeset1);
my $out = $self->name2code($name,$codeset2);
return $out;
}
###############################################################################
# @codes = $o->all_codes([CODESET] [,'retired']);
# @names = $o->all_names([CODESET] [,'retired']);
#
# Returns all codes/names in the specified codeset, including retired
# ones if the option is given.
sub all_codes {
my($self,@args) = @_;
my $retired = 0;
if (@args && defined($args[$#args]) && lc($args[$#args]) eq 'retired') {
pop(@args);
$retired = 1;
}
# uncoverable branch true
if (! $$self{'type'}) {
# uncoverable statement
carp "ERROR: no type set for Locale::Codes object\n" if ($$self{'err'});
# uncoverable statement
return (1);
}
my $type = $$self{'type'};
my ($err,$tmp,$codeset) = $self->_code('',@args);
return () if ($err);
my @codes = keys %{ $Data{$type}{'code2id'}{$codeset} };
push(@codes,keys %{ $Retired{$type}{$codeset}{'code'} }) if ($retired);
return (sort @codes);
}
sub all_names {
my($self,@args) = @_;
my $retired = 0;
if (@args && defined($args[$#args]) && lc($args[$#args]) eq 'retired') {
pop(@args);
$retired = 1;
}
# uncoverable branch true
if (! $$self{'type'}) {
# uncoverable statement
carp "ERROR: no type set for Locale::Codes object\n" if ($$self{'err'});
# uncoverable statement
return (1);
}
my $type = $$self{'type'};
my ($err,$tmp,$codeset) = $self->_code('',@args);
return () if ($err);
my @codes = $self->all_codes($codeset);
my @names;
foreach my $code (@codes) {
my($id,$i) = @{ $Data{$type}{'code2id'}{$codeset}{$code} };
my $name = $Data{$type}{'id2names'}{$id}[$i];
push(@names,$name);
}
if ($retired) {
foreach my $lc (keys %{ $Retired{$type}{$codeset}{'name'} }) {
my $name = $Retired{$type}{$codeset}{'name'}{$lc}[1];
push @names,$name;
}
}
return (sort @names);
}
###############################################################################
# $flag = $o->rename_code (CODE,NEW_NAME [,CODESET])
#
# Change the official name for a code. The original is retained
# as an alias, but the new name will be returned if you lookup the
# name from code.
#
# Returns 1 on success.
#
sub rename_code {
my($self,$code,$new_name,$codeset) = @_;
# uncoverable branch true
if (! $$self{'type'}) {
# uncoverable statement
carp "ERROR: no type set for Locale::Codes object\n" if ($$self{'err'});
# uncoverable statement
return 0;
}
my $type = $$self{'type'};
# Make sure $code/$codeset are both valid
my($err,$c,$cs) = $self->_code($code,$codeset);
if ($err) {
carp "ERROR: rename: Unknown code/codeset: $code [$codeset]\n"
if ($$self{'err'});
return 0;
}
($code,$codeset) = ($c,$cs);
# Cases:
# 1. Renaming to a name which exists with a different ID
# Error
#
# 2. Renaming to a name which exists with the same ID
# Just change code2id (I value)
#
# 3. Renaming to a new name
# Create a new alias
# Change code2id (I value)
my $id = $Data{$type}{'code2id'}{$codeset}{$code}[0];
if (exists $Data{$type}{'alias2id'}{lc($new_name)}) {
# Existing name (case 1 and 2)
my ($new_id,$i) = @{ $Data{$type}{'alias2id'}{lc($new_name)} };
if ($new_id != $id) {
# Case 1
carp "ERROR: rename: rename to an existing name not allowed\n"
if ($$self{'err'});
return 0;
}
# Case 2
$Data{$type}{'code2id'}{$codeset}{$code}[1] = $i;
} else {
# Case 3
push @{ $Data{$type}{'id2names'}{$id} },$new_name;
my $i = $#{ $Data{$type}{'id2names'}{$id} };
$Data{$type}{'alias2id'}{lc($new_name)} = [ $id,$i ];
$Data{$type}{'code2id'}{$codeset}{$code}[1] = $i;
}
return 1;
}
###############################################################################
# $flag = $o->add_code (CODE,NAME [,CODESET])
#
# Add a new code to the codeset. Both CODE and NAME must be
# unused in the code set.
#
sub add_code {
my($self,$code,$name,$codeset) = @_;
# uncoverable branch true
if (! $$self{'type'}) {
# uncoverable statement
carp "ERROR: no type set for Locale::Codes object\n" if ($$self{'err'});
# uncoverable statement
return 0;
}
my $type = $$self{'type'};
# Make sure that $codeset is valid.
my($err,$c,$cs) = $self->_code($code,$codeset,1);
if ($err) {
carp "ERROR: rename: Unknown codeset: $codeset\n"
if ($$self{'err'});
return 0;
}
($code,$codeset) = ($c,$cs);
# Check that $code is unused.
if (exists $Data{$type}{'code2id'}{$codeset}{$code} ||
exists $Data{$type}{'codealias'}{$codeset}{$code}) {
carp "add_code: code already in use: $code\n" if ($$self{'err'});
return 0;
}
# Check to see that $name is unused in this code set. If it is
# used (but not in this code set), we'll use that ID. Otherwise,
# we'll need to get the next available ID.
my ($id,$i);
if (exists $Data{$type}{'alias2id'}{lc($name)}) {
($id,$i) = @{ $Data{$type}{'alias2id'}{lc($name)} };
if (exists $Data{$type}{'id2code'}{$codeset}{$id}) {
carp "add_code: name already in use: $name\n" if ($$self{'err'});
return 0;
}
} else {
$id = $Data{$type}{'id'}++;
$i = 0;
$Data{$type}{'alias2id'}{lc($name)} = [ $id,$i ];
$Data{$type}{'id2names'}{$id} = [ $name ];
}
# Add the new code
$Data{$type}{'code2id'}{$codeset}{$code} = [ $id,$i ];
$Data{$type}{'id2code'}{$codeset}{$id} = $code;
return 1;
}
###############################################################################
# $flag = $o->delete_code (CODE [,CODESET])
#
# Delete a code from the codeset.
#
sub delete_code {
my($self,$code,$codeset) = @_;
# uncoverable branch true
if (! $$self{'type'}) {
# uncoverable statement
carp "ERROR: no type set for Locale::Codes object\n" if ($$self{'err'});
# uncoverable statement
return 0;
}
my $type = $$self{'type'};
# Make sure $code/$codeset are both valid
my($err,$c,$cs) = $self->_code($code,$codeset);
# uncoverable branch true
if ($err) {
# uncoverable statement
carp "ERROR: rename: Unknown code/codeset: $code [$codeset]\n"
if ($$self{'err'});
# uncoverable statement
return 0;
}
($code,$codeset) = ($c,$cs);
# Delete the code
my $id = $Data{$type}{'code2id'}{$codeset}{$code}[0];
delete $Data{$type}{'code2id'}{$codeset}{$code};
delete $Data{$type}{'id2code'}{$codeset}{$id};
# Delete any aliases that are linked to this code
foreach my $alias (keys %{ $Data{$type}{'codealias'}{$codeset} }) {
next if ($Data{$type}{'codealias'}{$codeset}{$alias} ne $code);
delete $Data{$type}{'codealias'}{$codeset}{$alias};
}
# If this ID is not used in any other codeset, delete it completely.
foreach my $c (keys %{ $Data{$type}{'id2code'} }) {
return 1 if (exists $Data{$type}{'id2code'}{$c}{$id});
}
my @names = @{ $Data{$type}{'id2names'}{$id} };
delete $Data{$type}{'id2names'}{$id};
foreach my $name (@names) {
delete $Data{$type}{'alias2id'}{lc($name)};
}
return 1;
}
###############################################################################
# $flag = $o->add_alias (NAME,NEW_NAME)
#
# Add a new alias. NAME must exist, and NEW_NAME must be unused.
#
sub add_alias {
my($self,$name,$new_name) = @_;
# uncoverable branch true
if (! $$self{'type'}) {
# uncoverable statement
carp "ERROR: no type set for Locale::Codes object\n" if ($$self{'err'});
# uncoverable statement
return 0;
}
my $type = $$self{'type'};
# Check that $name is used and $new_name is new.
my($id);
if (exists $Data{$type}{'alias2id'}{lc($name)}) {
$id = $Data{$type}{'alias2id'}{lc($name)}[0];
} else {
carp "add_alias: name does not exist: $name\n" if ($$self{'err'});
return 0;
}
if (exists $Data{$type}{'alias2id'}{lc($new_name)}) {
carp "add_alias: alias already in use: $new_name\n" if ($$self{'err'});
return 0;
}
# Add the new alias
push @{ $Data{$type}{'id2names'}{$id} },$new_name;
my $i = $#{ $Data{$type}{'id2names'}{$id} };
$Data{$type}{'alias2id'}{lc($new_name)} = [ $id,$i ];
return 1;
}
###############################################################################
# $flag = $o->delete_alias (NAME)
#
# This deletes a name from the list of names used by an element.
# NAME must be used, but must NOT be the only name in the list.
#
# Any id2name that references this name will be changed to
# refer to the first name in the list.
#
sub delete_alias {
my($self,$name) = @_;
# uncoverable branch true
if (! $$self{'type'}) {
# uncoverable statement
carp "ERROR: no type set for Locale::Codes object\n" if ($$self{'err'});
# uncoverable statement
return 0;
}
my $type = $$self{'type'};
# Check that $name is used.
my($id,$i);
if (exists $Data{$type}{'alias2id'}{lc($name)}) {
($id,$i) = @{ $Data{$type}{'alias2id'}{lc($name)} };
} else {
carp "delete_alias: name does not exist: $name\n" if ($$self{'err'});
return 0;
}
my $n = $#{ $Data{$type}{'id2names'}{$id} } + 1;
if ($n == 1) {
carp "delete_alias: only one name defined (use delete_code instead)\n"
if ($$self{'err'});
return 0;
}
# Delete the alias.
splice (@{ $Data{$type}{'id2names'}{$id} },$i,1);
delete $Data{$type}{'alias2id'}{lc($name)};
# Every element that refers to this ID:
# Ignore if I < $i
# Set to 0 if I = $i
# Decrement if I > $i
foreach my $codeset (keys %{ $Data{$type}{'code2id'} }) {
foreach my $code (keys %{ $Data{$type}{'code2id'}{$codeset} }) {
my($jd,$j) = @{ $Data{$type}{'code2id'}{$codeset}{$code} };
next if ($jd ne $id ||
$j < $i);
if ($i == $j) {
$Data{$type}{'code2id'}{$codeset}{$code}[1] = 0;
} else {
$Data{$type}{'code2id'}{$codeset}{$code}[1]--;
}
}
}
return 1;
}
###############################################################################
# $flag = $o->replace_code (CODE,NEW_CODE [,CODESET])
#
# Change the official code. The original is retained as an alias, but
# the new code will be returned if do a name2code lookup.
#
sub replace_code {
my($self,$code,$new_code,$codeset) = @_;
# uncoverable branch true
if (! $$self{'type'}) {
# uncoverable statement
carp "ERROR: no type set for Locale::Codes object\n" if ($$self{'err'});
# uncoverable statement
return 0;
}
my $type = $$self{'type'};
# Make sure $code/$codeset are both valid (and that $new_code is the
# correct format)
my($err,$c,$cs) = $self->_code($code,$codeset);
if ($err) {
carp "ERROR: rename_code: Unknown code/codeset: $code [$codeset]\n"
if ($$self{'err'});
return 0;
}
($code,$codeset) = ($c,$cs);
($err,$new_code,$codeset) = $self->_code($new_code,$codeset,1);
# Cases:
# 1. Renaming code to an existing alias of this code:
# Make the alias real and the code an alias
#
# 2. Renaming code to some other existing alias:
# Error
#
# 3. Renaming code to some other code:
# Error (
#
# 4. Renaming code to a new code:
# Make code into an alias
# Replace code with new_code.
if (exists $Data{$type}{'codealias'}{$codeset}{$new_code}) {
# Cases 1 and 2
if ($Data{$type}{'codealias'}{$codeset}{$new_code} eq $code) {
# Case 1
delete $Data{$type}{'codealias'}{$codeset}{$new_code};
} else {
# Case 2
carp "rename_code: new code already in use: $new_code\n"
if ($$self{'err'});
return 0;
}
} elsif (exists $Data{$type}{'code2id'}{$codeset}{$new_code}) {
# Case 3
carp "rename_code: new code already in use: $new_code\n"
if ($$self{'err'});
return 0;
}
# Cases 1 and 4
$Data{$type}{'codealias'}{$codeset}{$code} = $new_code;
my $id = $Data{$type}{'code2id'}{$codeset}{$code}[0];
$Data{$type}{'code2id'}{$codeset}{$new_code} =
$Data{$type}{'code2id'}{$codeset}{$code};
delete $Data{$type}{'code2id'}{$codeset}{$code};
$Data{$type}{'id2code'}{$codeset}{$id} = $new_code;
return 1;
}
###############################################################################
# $flag = $o->add_code_alias (CODE,NEW_CODE [,CODESET])
#
# Adds an alias for the code.
#
sub add_code_alias {
my($self,$code,$new_code,$codeset) = @_;
# uncoverable branch true
if (! $$self{'type'}) {
# uncoverable statement
carp "ERROR: no type set for Locale::Codes object\n" if ($$self{'err'});
# uncoverable statement
return 0;
}
my $type = $$self{'type'};
# Make sure $code/$codeset are both valid and that the new code is
# properly formatted.
my($err,$c,$cs) = $self->_code($code,$codeset);
if ($err) {
carp "ERROR: add_code_alias: Unknown code/codeset: $code [$codeset]\n"
if ($$self{'err'});
return 0;
}
($code,$codeset) = ($c,$cs);
($err,$new_code,$cs) = $self->_code($new_code,$codeset,1);
# Check that $new_code does not exist.
if (exists $Data{$type}{'code2id'}{$codeset}{$new_code} ||
exists $Data{$type}{'codealias'}{$codeset}{$new_code}) {
# uncoverable branch true
carp "add_code_alias: code already in use: $new_code\n" if ($$self{'err'});
return 0;
}
# Add the alias
$Data{$type}{'codealias'}{$codeset}{$new_code} = $code;
return 1;
}
###############################################################################
# $flag = $o->delete_code_alias (ALIAS [,CODESET])
#
# Deletes an alias for the code.
#
sub delete_code_alias {
my($self,$code,$codeset) = @_;
# uncoverable branch true
if (! $$self{'type'}) {
# uncoverable statement
carp "ERROR: no type set for Locale::Codes object\n" if ($$self{'err'});
# uncoverable statement
return 0;
}
my $type = $$self{'type'};
# Make sure $code/$codeset are both valid
my($err,$c,$cs) = $self->_code($code,$codeset);
if ($err) {
# uncoverable branch true
carp "ERROR: rename: Unknown code/codeset: $code [$codeset]\n"
if ($$self{'err'});
return 0;
}
($code,$codeset) = ($c,$cs);
# Check that $code exists in the codeset as an alias.
if (! exists $Data{$type}{'codealias'}{$codeset}{$code}) {
# uncoverable branch true
carp "delete_code_alias(): no alias defined: $code\n" if ($$self{'err'});
return 0;
}
# Delete the alias
delete $Data{$type}{'codealias'}{$codeset}{$code};
return 1;
}
1;
# Local Variables:
# mode: cperl
# indent-tabs-mode: nil
# cperl-indent-level: 3
# cperl-continued-statement-offset: 2
# cperl-continued-brace-offset: 0
# cperl-brace-offset: 0
# cperl-brace-imaginary-offset: 0
# cperl-label-offset: 0
# End:
Codes/LangFam.pod 0000644 00000006143 15051136664 0007625 0 ustar 00 =pod
=head1 NAME
Locale::Codes::LangFam - module for dealing with langfam code sets
=head1 SYNOPSIS
use Locale::Codes::LangFam;
$name = code2langfam(CODE);
$code = langfam2code(NAME);
@codes = all_langfam_codes();
@names = all_langfam_names();
=head1 DESCRIPTION
This module provides access to langfam code sets.
Please refer to the L<Locale::Codes::Types> document for a description
of the code sets available.
Most of the routines take an optional additional argument which
specifies the code set to use. The code set can be specified using the
name of a code set, or the perl constant specified in the above
document. If not specified, the default code set will be used.
=head1 ROUTINES
All routines in this module call the appropriate method in the
L<Locale::Codes> module, using an object of type: langfam
Please refer to the documentation of the L<Locale::Codes> module
for details about each function.
The following functions are exported automatically:
=over 4
=item B<code2langfam(CODE [,CODESET] [,'retired'])>
See B<code2name> in L<Locale::Codes>
=item B<langfam2code(NAME [,CODESET] [,'retired'])>
See B<name2code> in L<Locale::Codes>
=item B<langfam_code2code(CODE ,CODESET ,CODESET2)>
See B<code2code> in L<Locale::Codes>
=item B<all_langfam_codes([CODESET] [,'retired'])>
See B<all_codes> in L<Locale::Codes>
=item B<all_langfam_names([CODESET] [,'retired'])>
See B<all_names> in L<Locale::Codes>
=back
The following functions are not exported and must be called fully
qualified with the package name:
=over 4
=item B<Locale::Codes::Langfam::show_errors(FLAG)>
By default, invalid input will produce empty results, but no errors. By
passing in a non-zero value of FLAG, errors will be produced.
See B<show_errors> in L<Locale::Codes> but note that the default for
the non-OO modules are to NOT produce errors.
=item B<Locale::Codes::Langfam::rename_langfam(CODE ,NEW_NAME [,CODESET])>
See B<rename_code> in L<Locale::Codes>
=item B<Locale::Codes::Langfam::add_langfam(CODE ,NAME [,CODESET])>
See B<add_code> in L<Locale::Codes>
=item B<Locale::Codes::Langfam::delete_langfam(CODE [,CODESET])>
See B<delete_code> in L<Locale::Codes>
=item B<Locale::Codes::Langfam::add_langfam_alias(NAME ,NEW_NAME)>
See B<add_alias> in L<Locale::Codes>
=item B<Locale::Codes::Langfam::delete_langfam_alias(NAME)>
See B<delete_alias> in L<Locale::Codes>
=item B<Locale::Codes::Langfam::rename_langfam_code(CODE ,NEW_CODE [,CODESET])>
See B<replace_code> in L<Locale::Codes>
=item B<Locale::Codes::Langfam::add_langfam_code_alias(CODE ,NEW_CODE [,CODESET])>
See B<add_code_alias> in L<Locale::Codes>
=item B<Locale::Codes::Langfam::delete_langfam_code_alias(CODE [,CODESET])>
See B<delete_code_alias> in L<Locale::Codes>
=back
=head1 SEE ALSO
=over 4
=item L<Locale::Codes>
The Locale-Codes distribution.
=back
=head1 AUTHOR
See Locale::Codes for full author history.
Currently maintained by Sullivan Beck (sbeck@cpan.org).
=head1 COPYRIGHT
Copyright (c) 2011-2018 Sullivan Beck
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
=cut
Codes/LangFam.pm 0000644 00000003543 15051136664 0007460 0 ustar 00 package Locale::Codes::LangFam;
# Copyright (C) 2001 Canon Research Centre Europe (CRE).
# Copyright (C) 2002-2009 Neil Bowers
# Copyright (c) 2010-2018 Sullivan Beck
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# This file was automatically generated. Any changes to this file will
# be lost the next time 'gen_mods' is run.
# Generated on: Wed May 30 10:22:15 EDT 2018
use strict;
use warnings;
require 5.006;
use Exporter qw(import);
our($VERSION,@EXPORT);
$VERSION = '3.57';
################################################################################
use if $] >= 5.027007, 'deprecate';
use Locale::Codes;
use Locale::Codes::Constants;
@EXPORT = qw(
code2langfam
langfam2code
all_langfam_codes
all_langfam_names
langfam_code2code
);
push(@EXPORT,@Locale::Codes::Constants::CONSTANTS_LANGFAM);
our $obj = new Locale::Codes('langfam');
$obj->show_errors(0);
sub show_errors {
my($val) = @_;
$obj->show_errors($val);
}
sub code2langfam {
return $obj->code2name(@_);
}
sub langfam2code {
return $obj->name2code(@_);
}
sub langfam_code2code {
return $obj->code2code(@_);
}
sub all_langfam_codes {
return $obj->all_codes(@_);
}
sub all_langfam_names {
return $obj->all_names(@_);
}
sub rename_langfam {
return $obj->rename_code(@_);
}
sub add_langfam {
return $obj->add_code(@_);
}
sub delete_langfam {
return $obj->delete_code(@_);
}
sub add_langfam_alias {
return $obj->add_alias(@_);
}
sub delete_langfam_alias {
return $obj->delete_alias(@_);
}
sub rename_langfam_code {
return $obj->replace_code(@_);
}
sub add_langfam_code_alias {
return $obj->add_code_alias(@_);
}
sub delete_langfam_code_alias {
return $obj->delete_code_alias(@_);
}
1;
Codes/LangVar.pm 0000644 00000003543 15051136664 0007505 0 ustar 00 package Locale::Codes::LangVar;
# Copyright (C) 2001 Canon Research Centre Europe (CRE).
# Copyright (C) 2002-2009 Neil Bowers
# Copyright (c) 2010-2018 Sullivan Beck
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# This file was automatically generated. Any changes to this file will
# be lost the next time 'gen_mods' is run.
# Generated on: Wed May 30 10:22:15 EDT 2018
use strict;
use warnings;
require 5.006;
use Exporter qw(import);
our($VERSION,@EXPORT);
$VERSION = '3.57';
################################################################################
use if $] >= 5.027007, 'deprecate';
use Locale::Codes;
use Locale::Codes::Constants;
@EXPORT = qw(
code2langvar
langvar2code
all_langvar_codes
all_langvar_names
langvar_code2code
);
push(@EXPORT,@Locale::Codes::Constants::CONSTANTS_LANGVAR);
our $obj = new Locale::Codes('langvar');
$obj->show_errors(0);
sub show_errors {
my($val) = @_;
$obj->show_errors($val);
}
sub code2langvar {
return $obj->code2name(@_);
}
sub langvar2code {
return $obj->name2code(@_);
}
sub langvar_code2code {
return $obj->code2code(@_);
}
sub all_langvar_codes {
return $obj->all_codes(@_);
}
sub all_langvar_names {
return $obj->all_names(@_);
}
sub rename_langvar {
return $obj->rename_code(@_);
}
sub add_langvar {
return $obj->add_code(@_);
}
sub delete_langvar {
return $obj->delete_code(@_);
}
sub add_langvar_alias {
return $obj->add_alias(@_);
}
sub delete_langvar_alias {
return $obj->delete_alias(@_);
}
sub rename_langvar_code {
return $obj->replace_code(@_);
}
sub add_langvar_code_alias {
return $obj->add_code_alias(@_);
}
sub delete_langvar_code_alias {
return $obj->delete_code_alias(@_);
}
1;
Codes/Country_Retired.pm 0000644 00000070454 15051136664 0011301 0 ustar 00 package #
Locale::Codes::Country_Retired;
# This file was automatically generated. Any changes to this file will
# be lost the next time 'deprecate_codes' is run.
# Generated on: Wed May 30 10:26:44 EDT 2018
use strict;
require 5.006;
use warnings;
use utf8;
our($VERSION);
$VERSION='3.57';
$Locale::Codes::Retired{'country'}{'alpha-2'}{'code'} = {
q(an) => q(Netherlands Antilles),
q(cs) => q(Serbia and Montenegro),
q(fx) => q(France, Metropolitan),
q(tp) => q(East Timor),
q(yu) => q(Yugoslavia),
q(zr) => q(Zaire),
};
$Locale::Codes::Retired{'country'}{'alpha-3'}{'code'} = {
q(ant) => q(Netherlands Antilles),
q(ata) => q(Antarctica),
q(atf) => q(French Southern and Antarctic Lands),
q(bvt) => q(Bouvet Island),
q(cck) => q(Cocos (Keeling) Islands),
q(cxr) => q(Christmas Island),
q(fxx) => q(France, Metropolitan),
q(hmd) => q(Heard Island and Mcdonald Islands),
q(iot) => q(British Indian Ocean Territory),
q(rom) => q(Romania),
q(scg) => q(Serbia and Montenegro),
q(sgs) => q(South Georgia and the Islands),
q(tmp) => q(East Timor),
q(twn) => q(Taiwan),
q(umi) => q(United States Minor Outlying Islands),
q(yug) => q(Yugoslavia),
q(zar) => q(Zaire),
};
$Locale::Codes::Retired{'country'}{'dom'}{'code'} = {
q(AC) => q(Ascension Island),
q(AD) => q(Andorra),
q(AE) => q(United Arab Emirates),
q(AF) => q(Afghanistan),
q(AG) => q(Antigua and Barbuda),
q(AI) => q(Anguilla),
q(AL) => q(Albania),
q(AM) => q(Armenia),
q(AN) => q(Netherlands Antilles),
q(AO) => q(Angola),
q(AQ) => q(Antarctica),
q(AR) => q(Argentina),
q(AS) => q(American Samoa),
q(AT) => q(Austria),
q(AU) => q(Australia),
q(AW) => q(Aruba),
q(AX) => q(Aland Islands),
q(AZ) => q(Azerbaijan),
q(BA) => q(Bosnia and Herzegovina),
q(BB) => q(Barbados),
q(BD) => q(Bangladesh),
q(BE) => q(Belgium),
q(BF) => q(Burkina Faso),
q(BG) => q(Bulgaria),
q(BH) => q(Bahrain),
q(BI) => q(Burundi),
q(BJ) => q(Benin),
q(BL) => q(Saint Barthelemy),
q(BM) => q(Bermuda),
q(BN) => q(Brunei Darussalam),
q(BO) => q(Bolivia, Plurinational State of),
q(BQ) => q(Bonaire, Sint Eustatius and Saba),
q(BR) => q(Brazil),
q(BS) => q(Bahamas),
q(BT) => q(Bhutan),
q(BV) => q(Bouvet Island),
q(BW) => q(Botswana),
q(BY) => q(Belarus),
q(BZ) => q(Belize),
q(CA) => q(Canada),
q(CC) => q(Cocos (Keeling) Islands),
q(CD) => q(Congo, The Democratic Republic of the),
q(CF) => q(Central African Republic),
q(CG) => q(Congo),
q(CH) => q(Switzerland),
q(CI) => q(Cote d'Ivoire),
q(CK) => q(Cook Islands),
q(CL) => q(Chile),
q(CM) => q(Cameroon),
q(CN) => q(China),
q(CO) => q(Colombia),
q(CR) => q(Costa Rica),
q(CU) => q(Cuba),
q(CV) => q(Cape Verde),
q(CW) => q(Curacao),
q(CX) => q(Christmas Island),
q(CY) => q(Cyprus),
q(CZ) => q(Czech Republic),
q(DE) => q(Germany),
q(DJ) => q(Djibouti),
q(DK) => q(Denmark),
q(DM) => q(Dominica),
q(DO) => q(Dominican Republic),
q(DZ) => q(Algeria),
q(EC) => q(Ecuador),
q(EE) => q(Estonia),
q(EG) => q(Egypt),
q(EH) => q(Western Sahara),
q(ER) => q(Eritrea),
q(ES) => q(Spain),
q(ET) => q(Ethiopia),
q(EU) => q(European Union),
q(FI) => q(Finland),
q(FJ) => q(Fiji),
q(FK) => q(Falkland Islands (Malvinas)),
q(FM) => q(Micronesia, Federated States of),
q(FO) => q(Faroe Islands),
q(FR) => q(France),
q(FX) => q(France, Metropolitan),
q(GA) => q(Gabon),
q(GB) => q(United Kingdom),
q(GD) => q(Grenada),
q(GE) => q(Georgia),
q(GF) => q(French Guiana),
q(GG) => q(Guernsey),
q(GH) => q(Ghana),
q(GI) => q(Gibraltar),
q(GL) => q(Greenland),
q(GM) => q(Gambia),
q(GN) => q(Guinea),
q(GP) => q(Guadeloupe),
q(GQ) => q(Equatorial Guinea),
q(GR) => q(Greece),
q(GS) => q(South Georgia and the South Sandwich Islands),
q(GT) => q(Guatemala),
q(GU) => q(Guam),
q(GW) => q(Guinea-Bissau),
q(GY) => q(Guyana),
q(HK) => q(Hong Kong),
q(HM) => q(Heard Island and Mcdonald Islands),
q(HN) => q(Honduras),
q(HR) => q(Croatia),
q(HT) => q(Haiti),
q(HU) => q(Hungary),
q(ID) => q(Indonesia),
q(IE) => q(Ireland),
q(IL) => q(Israel),
q(IM) => q(Isle of Man),
q(IN) => q(India),
q(IO) => q(British Indian Ocean Territory),
q(IQ) => q(Iraq),
q(IR) => q(Iran, Islamic Republic of),
q(IS) => q(Iceland),
q(IT) => q(Italy),
q(JE) => q(Jersey),
q(JM) => q(Jamaica),
q(JO) => q(Jordan),
q(JP) => q(Japan),
q(KE) => q(Kenya),
q(KG) => q(Kyrgyzstan),
q(KH) => q(Cambodia),
q(KI) => q(Kiribati),
q(KM) => q(Comoros),
q(KN) => q(Saint Kitts and Nevis),
q(KP) => q(Korea, Democratic People's Republic of),
q(KR) => q(Korea, Republic of),
q(KW) => q(Kuwait),
q(KY) => q(Cayman Islands),
q(KZ) => q(Kazakhstan),
q(LA) => q(Lao People's Democratic Republic),
q(LB) => q(Lebanon),
q(LC) => q(Saint Lucia),
q(LI) => q(Liechtenstein),
q(LK) => q(Sri Lanka),
q(LR) => q(Liberia),
q(LS) => q(Lesotho),
q(LT) => q(Lithuania),
q(LU) => q(Luxembourg),
q(LV) => q(Latvia),
q(LY) => q(Libya),
q(MA) => q(Morocco),
q(MC) => q(Monaco),
q(MD) => q(Moldova, Republic of),
q(ME) => q(Montenegro),
q(MF) => q(Saint Martin (French part)),
q(MG) => q(Madagascar),
q(MH) => q(Marshall Islands),
q(MK) => q(Macedonia, The Former Yugoslav Republic of),
q(ML) => q(Mali),
q(MM) => q(Myanmar),
q(MN) => q(Mongolia),
q(MO) => q(Macao),
q(MP) => q(Northern Mariana Islands),
q(MQ) => q(Martinique),
q(MR) => q(Mauritania),
q(MS) => q(Montserrat),
q(MT) => q(Malta),
q(MU) => q(Mauritius),
q(MV) => q(Maldives),
q(MW) => q(Malawi),
q(MX) => q(Mexico),
q(MY) => q(Malaysia),
q(MZ) => q(Mozambique),
q(NA) => q(Namibia),
q(NC) => q(New Caledonia),
q(NE) => q(Niger),
q(NF) => q(Norfolk Island),
q(NG) => q(Nigeria),
q(NI) => q(Nicaragua),
q(NL) => q(Netherlands),
q(NO) => q(Norway),
q(NP) => q(Nepal),
q(NR) => q(Nauru),
q(NU) => q(Niue),
q(NZ) => q(New Zealand),
q(OM) => q(Oman),
q(PA) => q(Panama),
q(PE) => q(Peru),
q(PF) => q(French Polynesia),
q(PG) => q(Papua New Guinea),
q(PH) => q(Philippines),
q(PK) => q(Pakistan),
q(PL) => q(Poland),
q(PM) => q(Saint Pierre and Miquelon),
q(PN) => q(Pitcairn),
q(PR) => q(Puerto Rico),
q(PS) => q(Palestinian Territory, Occupied),
q(PT) => q(Portugal),
q(PW) => q(Palau),
q(PY) => q(Paraguay),
q(QA) => q(Qatar),
q(RE) => q(Reunion),
q(RO) => q(Romania),
q(RS) => q(Serbia),
q(RU) => q(Russian Federation),
q(RW) => q(Rwanda),
q(SA) => q(Saudi Arabia),
q(SB) => q(Solomon Islands),
q(SC) => q(Seychelles),
q(SD) => q(Sudan),
q(SE) => q(Sweden),
q(SG) => q(Singapore),
q(SH) => q(Saint Helena, Ascension and Tristan da Cunha),
q(SI) => q(Slovenia),
q(SJ) => q(Svalbard and Jan Mayen),
q(SK) => q(Slovakia),
q(SL) => q(Sierra Leone),
q(SM) => q(San Marino),
q(SN) => q(Senegal),
q(SO) => q(Somalia),
q(SR) => q(Suriname),
q(SS) => q(South Sudan),
q(ST) => q(Sao Tome and Principe),
q(SU) => q(Soviet Union),
q(SV) => q(El Salvador),
q(SX) => q(Sint Maarten (Dutch part)),
q(SY) => q(Syrian Arab Republic),
q(SZ) => q(Swaziland),
q(TC) => q(Turks and Caicos Islands),
q(TD) => q(Chad),
q(TF) => q(French Southern Territories),
q(TG) => q(Togo),
q(TH) => q(Thailand),
q(TJ) => q(Tajikistan),
q(TK) => q(Tokelau),
q(TL) => q(Timor-Leste),
q(TM) => q(Turkmenistan),
q(TN) => q(Tunisia),
q(TO) => q(Tonga),
q(TP) => q(Portuguese Timor),
q(TR) => q(Turkey),
q(TT) => q(Trinidad and Tobago),
q(TV) => q(Tuvalu),
q(TW) => q(Taiwan, Province of China),
q(TZ) => q(Tanzania, United Republic of),
q(UA) => q(Ukraine),
q(UG) => q(Uganda),
q(UK) => q(United Kingdom),
q(UM) => q(United States Minor Outlying Islands),
q(US) => q(United States),
q(UY) => q(Uruguay),
q(UZ) => q(Uzbekistan),
q(VA) => q(Holy See (Vatican City State)),
q(VC) => q(Saint Vincent and the Grenadines),
q(VE) => q(Venezuela, Bolivarian Republic of),
q(VG) => q(Virgin Islands, British),
q(VI) => q(Virgin Islands, U.S.),
q(VN) => q(Viet Nam),
q(VU) => q(Vanuatu),
q(WF) => q(Wallis and Futuna),
q(WS) => q(Samoa),
q(YE) => q(Yemen),
q(YT) => q(Mayotte),
q(YU) => q(Yugoslavia ),
q(ZA) => q(South Africa),
q(ZM) => q(Zambia),
q(ZW) => q(Zimbabwe),
q(ac) => q(Ascension Island),
q(an) => q(Netherlands Antilles),
q(eu) => q(European Union),
q(su) => q(USSR),
q(tp) => q(East Timor),
q(uk) => q(United Kingdom),
};
$Locale::Codes::Retired{'country'}{'genc-alpha-2'}{'code'} = {
};
$Locale::Codes::Retired{'country'}{'genc-alpha-3'}{'code'} = {
};
$Locale::Codes::Retired{'country'}{'genc-numeric'}{'code'} = {
};
$Locale::Codes::Retired{'country'}{'numeric'}{'code'} = {
q(010) => q(Antarctica),
q(074) => q(Bouvet Island),
q(086) => q(British Indian Ocean Territory),
q(158) => q(Taiwan),
q(162) => q(Christmas Island),
q(166) => q(Cocos (Keeling) Islands),
q(239) => q(South Georgia and the Islands),
q(249) => q(France, Metropolitan),
q(260) => q(French Southern and Antarctic Lands),
q(334) => q(Heard Island and Mcdonald Islands),
q(530) => q(Netherlands Antilles),
q(581) => q(United States Minor Outlying Islands),
q(680) => q(Sark),
q(736) => q(Sudan),
q(830) => q(Channel Islands),
q(891) => q(Serbia and Montenegro),
};
$Locale::Codes::Retired{'country'}{'un-alpha-3'}{'code'} = {
};
$Locale::Codes::Retired{'country'}{'un-numeric'}{'code'} = {
q(830) => q(Channel Islands),
};
$Locale::Codes::Retired{'country'}{'alpha-2'}{'name'} = {
q(bolivia) => [ q(bo), q(Bolivia) ],
q(bolivia, plurinational state of) => [ q(bo), q(Bolivia, Plurinational State of) ],
q(bonaire, saint eustatius and saba) => [ q(bq), q(Bonaire, Saint Eustatius and Saba) ],
q(bosnia and herzegowina) => [ q(ba), q(Bosnia and Herzegowina) ],
q(cape verde) => [ q(cv), q(Cape Verde) ],
q(congo, the democratic republic of the) => [ q(cd), q(Congo, The Democratic Republic of the) ],
q(czech republic) => [ q(cz), q(Czech Republic) ],
q(east timor) => [ q(tl), q(East Timor) ],
q(falkland islands (malvinas)) => [ q(fk), q(Falkland Islands (Malvinas)) ],
q(france, metropolitan) => [ q(fx), q(France, Metropolitan) ],
q(heard and mc donald islands) => [ q(hm), q(Heard and Mc Donald Islands) ],
q(holy see (the) [vatican city state]) => [ q(va), q(Holy See (The) [Vatican City State]) ],
q(holy see (vatican city state)) => [ q(va), q(Holy See (Vatican City State)) ],
q(iran (islamic republic of)) => [ q(ir), q(Iran (Islamic Republic of)) ],
q(iran, islamic republic of) => [ q(ir), q(Iran, Islamic Republic of) ],
q(iran, the islamic republic of) => [ q(ir), q(Iran, The Islamic Republic of) ],
q(kazakstan) => [ q(kz), q(Kazakstan) ],
q(korea, democratic people's republic of) => [ q(kp), q(Korea, Democratic People's Republic of) ],
q(korea, republic of) => [ q(kr), q(Korea, Republic of) ],
q(libyan arab jamahiriya) => [ q(ly), q(Libyan Arab Jamahiriya) ],
q(macau) => [ q(mo), q(Macau) ],
q(micronesia (federated states of)) => [ q(fm), q(Micronesia (Federated States of)) ],
q(micronesia, federated states of) => [ q(fm), q(Micronesia, Federated States of) ],
q(micronesia, the federated states of) => [ q(fm), q(Micronesia, The Federated States of) ],
q(moldova, republic of) => [ q(md), q(Moldova, Republic of) ],
q(netherlands antilles) => [ q(an), q(Netherlands Antilles) ],
q(saint helena) => [ q(sh), q(Saint Helena) ],
q(saint martin) => [ q(mf), q(Saint Martin) ],
q(serbia and montenegro) => [ q(cs), q(Serbia and Montenegro) ],
q(st. helena) => [ q(sh), q(St. Helena) ],
q(st. pierre and miquelon) => [ q(pm), q(St. Pierre and Miquelon) ],
q(svalbard and jan mayen islands) => [ q(sj), q(Svalbard and Jan Mayen Islands) ],
q(taiwan, province of china) => [ q(tw), q(Taiwan, Province of China) ],
q(united kingdom) => [ q(gb), q(United Kingdom) ],
q(united states) => [ q(us), q(United States) ],
q(vatican city state (holy see)) => [ q(va), q(Vatican City State (Holy See)) ],
q(venezuela) => [ q(ve), q(Venezuela) ],
q(venezuela, bolivarian republic of) => [ q(ve), q(Venezuela, Bolivarian Republic of) ],
q(venezuela, bolivarian republic of ) => [ q(ve), q(Venezuela, Bolivarian Republic of ) ],
q(vietnam) => [ q(vn), q(Vietnam) ],
q(virgin islands (british)) => [ q(vg), q(Virgin Islands (British)) ],
q(virgin islands (u.s.)) => [ q(vi), q(Virgin Islands (U.S.)) ],
q(virgin islands, british) => [ q(vg), q(Virgin Islands, British) ],
q(virgin islands, u.s.) => [ q(vi), q(Virgin Islands, U.S.) ],
q(wallis and futuna islands) => [ q(wf), q(Wallis and Futuna Islands) ],
q(yugoslavia) => [ q(yu), q(Yugoslavia) ],
q(zaire) => [ q(zr), q(Zaire) ],
};
$Locale::Codes::Retired{'country'}{'alpha-3'}{'name'} = {
q(antarctica) => [ q(ata), q(Antarctica) ],
q(bolivia) => [ q(bol), q(Bolivia) ],
q(bolivia (plurinational state of)) => [ q(bol), q(Bolivia (Plurinational State of)) ],
q(bolivia, plurinational state of) => [ q(bol), q(Bolivia, Plurinational State of) ],
q(bonaire, saint eustatius and saba) => [ q(bes), q(Bonaire, Saint Eustatius and Saba) ],
q(bouvet island) => [ q(bvt), q(Bouvet Island) ],
q(british indian ocean territory) => [ q(iot), q(British Indian Ocean Territory) ],
q(british virgin islands) => [ q(vgb), q(British Virgin Islands) ],
q(cabo verde) => [ q(cpv), q(Cabo Verde) ],
q(cape verde) => [ q(cpv), q(Cape Verde) ],
q(china, hong kong special administrative region) => [ q(hkg), q(China, Hong Kong Special Administrative Region) ],
q(china, macao special administrative region) => [ q(mac), q(China, Macao Special Administrative Region) ],
q(christmas island) => [ q(cxr), q(Christmas Island) ],
q(cocos (keeling) islands) => [ q(cck), q(Cocos (Keeling) Islands) ],
q(congo, the democratic republic of the) => [ q(cod), q(Congo, The Democratic Republic of the) ],
q(czech republic) => [ q(cze), q(Czech Republic) ],
q(democratic people's republic of korea) => [ q(prk), q(Democratic People's Republic of Korea) ],
q(democratic republic of the congo) => [ q(cod), q(Democratic Republic of the Congo) ],
q(east timor) => [ q(tls), q(East Timor) ],
q(faeroe islands) => [ q(fro), q(Faeroe Islands) ],
q(falkland islands (malvinas)) => [ q(flk), q(Falkland Islands (Malvinas)) ],
q(faroe islands) => [ q(fro), q(Faroe Islands) ],
q(france, metropolitan) => [ q(fxx), q(France, Metropolitan) ],
q(french southern and antarctic lands) => [ q(atf), q(French Southern and Antarctic Lands) ],
q(french southern territories) => [ q(atf), q(French Southern Territories) ],
q(heard island and mcdonald islands) => [ q(hmd), q(Heard Island and Mcdonald Islands) ],
q(holy see) => [ q(vat), q(Holy See) ],
q(holy see (the) [vatican city state]) => [ q(vat), q(Holy See (The) [Vatican City State]) ],
q(holy see (vatican city state)) => [ q(vat), q(Holy See (Vatican City State)) ],
q(hong kong) => [ q(hkg), q(Hong Kong) ],
q(hong kong special administrative region of china) => [ q(hkg), q(Hong Kong Special Administrative Region of China) ],
q(iran (islamic republic of)) => [ q(irn), q(Iran (Islamic Republic of)) ],
q(iran, islamic republic of) => [ q(irn), q(Iran, Islamic Republic of) ],
q(iran, the islamic republic of) => [ q(irn), q(Iran, The Islamic Republic of) ],
q(kazakstan) => [ q(kaz), q(Kazakstan) ],
q(korea, democratic people's republic of) => [ q(prk), q(Korea, Democratic People's Republic of) ],
q(korea, republic of) => [ q(kor), q(Korea, Republic of) ],
q(libyan arab jamahiriya) => [ q(lby), q(Libyan Arab Jamahiriya) ],
q(macao) => [ q(mac), q(Macao) ],
q(macao special administrative region of china) => [ q(mac), q(Macao Special Administrative Region of China) ],
q(macau) => [ q(mac), q(Macau) ],
q(macedonia, the former yugoslav republic of) => [ q(mkd), q(Macedonia, the Former Yugoslav Republic of) ],
q(microne