RFC5646 Parser: splits Language Tag into relevant ISO codes
Perl
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib/Net/IDN
t
.gitignore
Changes
LICENSE
MANIFEST
MYMETA.json
Makefile.PL
README.md

README.md

Net-IDN-LanguageTag


Net-IDN-LanguageTag attemts to automatically parse RFC5646 language tags into a Class::Accessor object and build as much information as possible. For example, if your language tag is en-GB (language-region), the accesssor will contain the following methods.

At the moment its a bit limited with more complex tags.

TODO: http://www.langtag.net/ has some regexs that might help...


Usage

$tag = Net::IDN::LanguageTag->new('en-GB-Latn'); # new object parses immediately  
print $tag->language(); # en  
print $tag->region(); # GB
print $tag->script(); # Latn  

# using ISO names
print $tag->iso639_1(); #  en  
print $tag->iso639_2(); # eng  
print $tag->iso3166_1(); # GB  
print $tag->iso15924(); # Latn

# human readable  
print $tag->language_name(); # English  
print $tag->region_name(); # United Kingdom  
print $tag->script_name(); # Latin   

See: http://tools.ietf.org/html/rfc5646