|
Lingua::Num2Word - wrapper for number to text conversion modules of various languages in the Lingua:: hierarchy. |
Lingua::Num2Word - wrapper for number to text conversion modules of various languages in the Lingua:: hierarchy.
use Lingua::Num2Word;
my $numbers = Lingua::Num2Word->new;
# try to use czech module (Lingua::CS::Num2Word) for conversion to text my $text = $numbers->cardinal( 'cs', 123 );
# or procedural usage if you dislike OO my $text = Lingua::Num2Word::cardinal( 'cs', 123 );
print $text || "sorry, can't convert this number into czech language.";
# check if number is in supported interval before conversion
my $number = 999_999_999_999;
my $limit = $numbers->get_interval('cs');
if ($limit) {
if ($number > $$limit[1] || $number < $$limit[0]) {
print "Number is outside of supported range - <$$limit[0], $$limit[1]>.";
} else {
print Lingua::Num2Word::cardinal( 'cs', $number );
}
} else {
print "Unsupported language.";
}
Lingua::Num2Word is a module for converting numbers into their equivalent in written representation. This is a wrapper for various Lingua::XX::Num2Word modules that do the conversions for specific languages. Output encoding is utf-8.
For further information about various limitations of the specific modules see their documentation.
cardinal(lang,number)get_interval(lang)
Language codes and names from iso639 can be found at http://www.triacom.com/archive/iso639.en.html
This module is only wrapper and require other cpan modules for requested conversions eg. Lingua::AF::Numbers for Afrikaans.
Currently supported languages/modules are:
None.
Roman Vasicek <rv@petamem.com>
Copyright (c) 2002-2004 PetaMem s.r.o. - http://www.petamem.com/
This package is free software. You can redistribute and/or modify it under the same terms as Perl itself.
|
Lingua::Num2Word - wrapper for number to text conversion modules of various languages in the Lingua:: hierarchy. |