NAME
Lingua::FR::Numbers - Converts numeric values into their French string equivalents
SYNOPSIS
# OO Style
use Lingua::FR::Numbers;
my $nombre = Lingua::FR::Numbers->new( 123 );
print $nombre->get_string;
my $autre_nombre = Lingua::FR::Numbers->new;
$autre_nombre->parse( 7340 );
$french_string = $autre_nombre->get_string;
# Function style
use Lingua::FR::Numbers qw(number_to_fr);
print number_to_fr( 345 );
DESCRIPTION
This module tries to convert a number into French cardinal numeral adjective. It supports decimals number, but this feature is experimental.
The interface tries to conform to the one defined in Lingua::EN::Number, though this module does not provide any parse() method. Also, notes that unlike Lingua::En::Numbers, you can use this module in a functionnal manner by importing the number_to_fr() function.
VARIABLES
- $Lingua::FR::Numbers::MODE
-
The current locale mode. Currently only 'fr_FR' (French from France) is supported.
FUNCTION-ORIENTED INTERFACE
number_to_fr( $number )
number_to_fr_FR($number)
use Lingua::FR::Numbers qw(number_to_fr);
my $depth = number_to_fr( 20_000 );
my $year = number_to_fr( 1870 );
print "Jules Vernes écrivit _$depth lieues sous les mers_ en $year.";
These two functions (which are the same at the moment) can be exported by the module.
OBJECT-ORIENTED INTERFACE
new( [ $number ] )
my $start = Lingua::FR::Numbers->new( 500 );
my $end = Lingua::FR::Numbers->new( 3000 );
print "Nous partîmes ", $start->get_string,
"; mais par un prompt renfort\n",
"Nous nous vîmes ", $end->get_string," en arrivant au port"
Creates and initialize a new instance of an object.
parse( $number )
Initialize (or reinitialize) the instance.
get_string( [ %options ] )
my $string = $number->get_string;
my $string = $number->get_string( MODE => 'fr_CH' );
Returns the number as a formatted string in French, lowercased. The hash of options can be used to set the locale to use for the output (currently unimplemented.)
TODO
better support for decimal numbers ( 1.05 != 1.5 or is it? )
support for fr_* languages.
- fr_FR - fr_BE - fr_CA - fr_CH - fr_LU
support for very large numbers ( sextillion de sextillion ... )/
DIAGNOSTICS
- Error: bad number format: '$number'.
-
(W) The number specified is not in a valid numeric format.
- Error: number too big: '$number'
-
(W) The number is to big to be converted into a string.
BUGS AND COMMENTS
Though the modules should be able to convert big numbers (up to 10**36), I do not know how perl handles them.
Probably a lot. If you find one, please use the Request Tracker Interface - http://rt.cpan.org/NoAuth/Bugs.html?Dist=Lingua-FR-Numbers to report it, thanks.
SOURCE
Le français correct - Maurice GREVISSE
Décret n° 61-501 du 3 mai 1961. relatif aux unités de mesure et au contrôle des instruments de mesure. - http://www.adminet.com/jo/dec61-501.html
COPYRIGHTS
Copyright (c) 2002, Briac Pilpré. All rights reserved. This code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
Briac Pilpré <briac@cpan.org>
SEE ALSO
Lingua::EN::Numbers
3 POD Errors
The following errors were encountered while parsing the POD:
- Around line 112:
'=item' outside of any '=over'
- Around line 117:
You forgot a '=back' before '=head1'
- Around line 126:
Non-ASCII character seen before =encoding in 'écrivit'. Assuming CP1252