1 package Locale::Codes::LangExt;
2 # Copyright (c) 2011-2011 Sullivan Beck
3 # This program is free software; you can redistribute it and/or modify it
4 # under the same terms as Perl itself.
13 use Locale::Codes::Constants;
14 use Locale::Codes::LangExt_Codes;
16 #=======================================================================
17 # Public Global Variables
18 #=======================================================================
20 our($VERSION,@ISA,@EXPORT,@EXPORT_OK);
24 @EXPORT = qw(code2langext
33 my($code,$codeset) = @_;
34 $code = "" if (! $code);
36 $codeset = LOCALE_LANGEXT_DEFAULT if (! defined($codeset) || $codeset eq "");
38 if ($codeset =~ /^\d+$/) {
39 if ($codeset == LOCALE_LANGEXT_ALPHA) {
46 if ($codeset eq "alpha") {
52 return (0,$code,$codeset);
55 #=======================================================================
57 # code2langext ( CODE [,CODESET] )
59 #=======================================================================
62 my($err,$code,$codeset) = _code(@_);
63 return undef if ($err ||
66 return Locale::Codes::_code2name("langext",$code,$codeset);
69 #=======================================================================
71 # langext2code ( LANGEXT [,CODESET] )
73 #=======================================================================
76 my($langext,$codeset) = @_;
78 ($err,$tmp,$codeset) = _code("",$codeset);
79 return undef if ($err ||
82 return Locale::Codes::_name2code("langext",$langext,$codeset);
85 #=======================================================================
87 # langext_code2code ( CODE,CODESET_IN,CODESET_OUT )
89 #=======================================================================
91 sub langext_code2code {
92 (@_ == 3) or croak "langext_code2code() takes 3 arguments!";
93 my($code,$inset,$outset) = @_;
95 ($err,$code,$inset) = _code($code,$inset);
96 return undef if ($err);
97 ($err,$tmp,$outset) = _code("",$outset);
98 return undef if ($err);
100 return Locale::Codes::_code2code("langext",$code,$inset,$outset);
103 #=======================================================================
105 # all_langext_codes ( [CODESET] )
107 #=======================================================================
109 sub all_langext_codes {
112 ($err,$tmp,$codeset) = _code("",$codeset);
115 return Locale::Codes::_all_codes("langext",$codeset);
119 #=======================================================================
121 # all_langext_names ( [CODESET] )
123 #=======================================================================
125 sub all_langext_names {
128 ($err,$tmp,$codeset) = _code("",$codeset);
131 return Locale::Codes::_all_names("langext",$codeset);
134 #=======================================================================
136 # rename_langext ( CODE,NAME [,CODESET] )
138 #=======================================================================
141 my($code,$new_name,@args) = @_;
143 $nowarn = 1, pop(@args) if (@args && $args[$#args] eq "nowarn");
144 my $codeset = shift(@args);
146 ($err,$code,$codeset) = _code($code,$codeset);
148 return Locale::Codes::_rename("langext",$code,$new_name,$codeset,$nowarn);
151 #=======================================================================
153 # add_langext ( CODE,NAME [,CODESET] )
155 #=======================================================================
158 my($code,$name,@args) = @_;
160 $nowarn = 1, pop(@args) if (@args && $args[$#args] eq "nowarn");
161 my $codeset = shift(@args);
163 ($err,$code,$codeset) = _code($code,$codeset);
165 return Locale::Codes::_add_code("langext",$code,$name,$codeset,$nowarn);
168 #=======================================================================
170 # delete_langext ( CODE [,CODESET] )
172 #=======================================================================
175 my($code,@args) = @_;
177 $nowarn = 1, pop(@args) if (@args && $args[$#args] eq "nowarn");
178 my $codeset = shift(@args);
180 ($err,$code,$codeset) = _code($code,$codeset);
182 return Locale::Codes::_delete_code("langext",$code,$codeset,$nowarn);
185 #=======================================================================
187 # add_langext_alias ( NAME,NEW_NAME )
189 #=======================================================================
191 sub add_langext_alias {
192 my($name,$new_name,$nowarn) = @_;
193 $nowarn = (defined($nowarn) && $nowarn eq "nowarn" ? 1 : 0);
195 return Locale::Codes::_add_alias("langext",$name,$new_name,$nowarn);
198 #=======================================================================
200 # delete_langext_alias ( NAME )
202 #=======================================================================
204 sub delete_langext_alias {
205 my($name,$nowarn) = @_;
206 $nowarn = (defined($nowarn) && $nowarn eq "nowarn" ? 1 : 0);
208 return Locale::Codes::_delete_alias("langext",$name,$nowarn);
211 #=======================================================================
213 # rename_langext_code ( CODE,NEW_CODE [,CODESET] )
215 #=======================================================================
217 sub rename_langext_code {
218 my($code,$new_code,@args) = @_;
220 $nowarn = 1, pop(@args) if (@args && $args[$#args] eq "nowarn");
221 my $codeset = shift(@args);
223 ($err,$code,$codeset) = _code($code,$codeset);
224 ($err,$new_code,$codeset) = _code($new_code,$codeset) if (! $err);
226 return Locale::Codes::_rename_code("langext",$code,$new_code,$codeset,$nowarn);
229 #=======================================================================
231 # add_langext_code_alias ( CODE,NEW_CODE [,CODESET] )
233 #=======================================================================
235 sub add_langext_code_alias {
236 my($code,$new_code,@args) = @_;
238 $nowarn = 1, pop(@args) if (@args && $args[$#args] eq "nowarn");
239 my $codeset = shift(@args);
241 ($err,$code,$codeset) = _code($code,$codeset);
242 ($err,$new_code,$codeset) = _code($new_code,$codeset) if (! $err);
244 return Locale::Codes::_add_code_alias("langext",$code,$new_code,$codeset,$nowarn);
247 #=======================================================================
249 # delete_langext_code_alias ( CODE [,CODESET] )
251 #=======================================================================
253 sub delete_langext_code_alias {
254 my($code,@args) = @_;
256 $nowarn = 1, pop(@args) if (@args && $args[$#args] eq "nowarn");
257 my $codeset = shift(@args);
259 ($err,$code,$codeset) = _code($code,$codeset);
261 return Locale::Codes::_delete_code_alias("langext",$code,$codeset,$nowarn);
267 # indent-tabs-mode: nil
268 # cperl-indent-level: 3
269 # cperl-continued-statement-offset: 2
270 # cperl-continued-brace-offset: 0
271 # cperl-brace-offset: 0
272 # cperl-brace-imaginary-offset: 0
273 # cperl-label-offset: -2