Burak Gürsoy > Lingua-Any-Numbers-0.45 > Lingua::Any::Numbers

Download:
Lingua-Any-Numbers-0.45.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.45   Source  

NAME ^

Lingua::Any::Numbers - Converts numbers into (any available language) string.

SYNOPSIS ^

   use Lingua::Any::Numbers qw(:std);
   printf "Available languages are: %s\n", join( ", ", available );
   printf "%s\n", to_string(  45 );
   printf "%s\n", to_ordinal( 45 );

or test all available languages

   use Lingua::Any::Numbers qw(:std);
   foreach my $lang ( available ) {
      printf "%s\n", to_string(  45, $lang );
      printf "%s\n", to_ordinal( 45, $lang );
   }

DESCRIPTION ^

This document describes version 0.45 of Lingua::Any::Numbers released on 24 October 2012.

The most popular Lingua modules are seem to be the ones that convert numbers into words. These kind of modules exist for a lot of languages. However, there is no standard interface defined for them. Most of the modules' interfaces are completely different and some do not implement the ordinal conversion at all. Lingua::Any::Numbers tries to create a common interface to call these different modules. And if a module has a known interface, but does not implement the required function/method then the number itself is returned instead of dying. It is also possible to take advantage of the automatic locale detection if you install all the supported modules listed in the "SEE ALSO" section.

Task::Lingua::Any::Numbers can be installed to get all the available modules related to Lingua::Any::Numbers on CPAN.

IMPORT PARAMETERS ^

All functions and aliases can be imported individually, but there are some predefined import tags:

   :all        Import everything (including aliases)
   :standard   available(), to_string(), to_ordinal().
   :std        Alias to :standard
   :standard2  available_languages(), to_string(), to_ordinal()
   :std2       Alias to :standard2
   :long       available_languages(), number_to_string(), number_to_ordinal()

IMPORT PRAGMAS ^

Some parameters enable/disable module features. + is prefixed to enable these options. Pragmas have global effect (i.e.: not lexical), they can not be disabled afterwards.

locale

Use the language from system locale:

   use Lingua::Any::Numbers qw(:std +locale);
   print to_string(81); # will use locale

However, the second parameter to the functions take precedence. If the language parameter is used, locale pragma will be discarded.

Install all the Lingua::*::Numbers modules to take advantage of the locale pragma.

It is also possible to enable locale usage through the functions. See "FUNCTIONS".

locale is implemented with I18N::LangTags::Detect.

FUNCTIONS ^

All language parameters (LANG) have a default value: EN. If it is set to LOCALE, then the language from the system locale will be used (if available).

to_string NUMBER [, LANG ]

Aliases:

num2str
number_to_string

to_ordinal NUMBER [, LANG ]

Aliases:

num2ord
number_to_ordinal

available

Returns a list of available language ids.

Aliases:

available_langs
available_languages

language_handler

Returns the name of the language handler class if you pass a language id and a class for that language id is loaded. Returns undef otherwise.

This function can not be imported. Use a fully qualified name to call:

   my $sv = language_handler('SV');

DEBUGGING ^

SILENT

If you define a sub named Lingua::Any::Numbers::SILENT and return a true value from that, then the module will not generate any warnings when it faces some recoverable errors.

Lingua::Any::Numbers::SILENT is not defined by default.

CAVEATS ^

SEE ALSO ^

   Lingua::AF::Numbers
   Lingua::BG::Numbers
   Lingua::EN::Numbers
   Lingua::EU::Numbers
   Lingua::FR::Numbers
   Lingua::HU::Numbers
   Lingua::IT::Numbers
   Lingua::JA::Numbers
   Lingua::NL::Numbers
   Lingua::PL::Numbers
   Lingua::SV::Numbers
   Lingua::TR::Numbers
   Lingua::ZH::Numbers
   
   Lingua::CS::Num2Word
   Lingua::DE::Num2Word
   Lingua::ES::Numeros
   Lingua::ID::Nums2Words
   Lingua::NO::Num2Word
   Lingua::PT::Nums2Word

You can just install Task::Lingua::Any::Numbers to get all modules above.

BOGUS MODULES

Some modules on CPAN suggest to convert numbers into words by their names, but they do something different instead. Here is a list of the bogus modules:

   Lingua::FA::Number

AUTHOR ^

Burak Gursoy <burak@cpan.org>.

COPYRIGHT ^

Copyright 2007 - 2012 Burak Gursoy. All rights reserved.

LICENSE ^

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.12.4 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: