NAME
Lingua::Num2Word
VERSION
version 0.0682
wrapper for number to text conversion modules of various languages in the Lingua:: hierarchy.
$Rev: 682 $
A wrapper for mosules in the Lingua::XXX hierarchy. XXX is a code from the ISO 639-3 namespace.
SYNOPSIS
use Lingua::Num2Word;
my $numbers = Lingua::Num2Word->new;
# try to use czech module (Lingua::CES::Num2Word) for conversion to text
my $text = $numbers->cardinal( 'ces', 123 );
# or procedural usage if you dislike OO
my $text = Lingua::Num2Word::cardinal( 'ces', 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('ces');
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( 'ces', $number );
}
}
else {
print "Unsupported language.";
}
DESCRIPTION
A wrapper for Lingua::XXX::num2word modules.
Lingua::Num2Word is a wrapper for modules for converting numbers into their equivalent in written representation.
This is a wrapper for various Lingua::XXX::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.
# }}} # {{{ Functions reference
Functions Reference
- cardinal (positional)
-
1 string target language 2 number number to convert => string converted string undef if input number is not supported
Conversion from number to text representation in specified language.
- get_interval (positional)
-
1 string language specification => array|arref list with min max values undef if specified language is not known
Returns the minimal and maximal number (inclusive) supported by the conversion in a specified language. The returned value is a list of two elements (low,high) or reference to this list depending on calling context. In case a unsupported language is passed undef is returned.
- known_langs
-
=> array|arref list of supproted languages
List of all currently supported languages. Return value is a list or a reference to a list depending on calling context.
- langs
-
=> array|arref list of languages known by ISO 639-3 list
List of all known language codes from iso639. Return value is list or reference to list depending on calling context.
- new
-
Constructor.
- preprocess_code
-
Private.
Language codes and names
Language codes and names from iso639 can be found at http://www.triacom.com/archive/iso639.en.html
EXPORT_OK
- cardinal
- get_interval
- known_langs
- langs
Required modules / supported languages
This module is only wrapper and requires other CPAN modules for requested conversions eg. Lingua::AFR::Numbers for Afrikaans.
Currently supported languages/modules are:
- afr - Lingua::AFR::Numbers
- ces - Lingua::CES::Num2Word
- deu - Lingua::DEU::Num2Word
- eng - Lingua::ENG::Numbers
- eus - Lingua::EUS::Numbers
- fra - Lingua::FRA::Numbers
- ind - Lingua::IND::Nums2Words
- ita - Lingua::ITA::Numbers
- jpn - Lingua::JPN::Number
- nld - Lingua::NLD::Numbers
- nor - Lingua::NOR::Num2Word
- pol - Lingua::POL::Numbers
- por - Lingua::POR::Nums2Words
- rus - Lingua::RUS::Number
- spa - Lingua::SPA::Numeros
- swe - Lingua::SWE::Num2Word
- zho - Lingua::ZHO::Numbers
AUTHOR
coding, maintenance, refactoring, extensions, specifications:
Richard C. Jelinek <info@petamem.com>
initial coding after specifications by R. Jelinek:
Roman Vasicek <info@petamem.com>
COPYRIGHT
Copyright (C) PetaMem, s.r.o. 2002-present
LICENSE
Artistic license or BSD license.