new util method proposition for Maketext

[email protected] (Guillaume Rousse) Sun, 1 Sep 2002 00:21:53 +0200
Newsgroups perl.i18n
Organization Université Pierre et Marie Curie
Message-ID <[email protected]>
The following method, loosely adapted from quant(), allows to deal with 
article variation in front of substantives beginning with a,e,i,o,u,y letters 
('voyelles' in french), a phenomenon called 'elision', such as le/l' in 
french. In english there also the a/an case. Maybe it would be useful for 
inclusion in Maketext ?

Note that user has to provide separation space if needed, in order to deal 
with 'apostrophe' case where it is not used:
le bateau -> article is "le "
l'avion -> article is "l'"

sub article {
    my ($self, $subst, @forms) = @_;

    return $subst unless @forms;

    if (@forms == 1) {
	return $forms[0] . $subst;
    } else {
	return $subst =~ /^[aeiouy]/i ?  $forms[1] . $subst : $forms[0] . $subst;
    }
	
}

BTW, this is a case where nested [ ] construct would be useful. In french, the 
article has different forms depending of substantive genera:
"le" for a male substantive
"la" for a female substantive
In german also (der/die/das), but as 'elision' doesn't exist, it isn't 
relevant for my demonstration :-)
Let's imagine we have a article_genera method, returning correct form for the 
article given different forms and genera, call to previous method could 
easily be wrotten using nested [ ] this way:
[article,_1,[article_genera,"le ","la ",_2],"l'"]

Is this a correct real-life argument :-) ?
-- 
Guillaume Rousse <[email protected]>
GPG key http://lis.snv.jussieu.fr/~rousse/gpgkey.html