bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC] automatic apostrophes


From: Bruno Haible
Subject: Re: [RFC] automatic apostrophes
Date: Tue, 29 Aug 2006 14:08:54 +0200
User-agent: KMail/1.9.1

Robert Millan wrote:
> There's a common limitation when localising programs for languages that use
> apostrophes with nouns.  For example:
> 
>   printf (_("%s greets you!"), argv[1]);
> 
>   $ ./test Owen
>   Owen greets you!
>   $ ./test Joe
>   Joe greets you!
> 
> When trying to localise this to Catalan, we face a problem.  Normaly, we would
> say "n'Owen et saluda!" because Owen starts with vowel, but "en Joe et 
> saluda!"
> because Joe starts with consonant.  E.g:
> 
>   $ ./test Owen
>   n'Owen et saluda!
>   $ ./test Joe
>   en Joe et saluda!
> 
> Unfortunately, when reading "%s greets you!", the translator can't tell wether
> %s will be starting with vowel or not [1].  I think it would be necessary for
> some mechanism to automaticaly convert "en Owen" to "n'Owen".  Then a 
> translator
> could just write "en %s" [2] and let gettext convert this accordingly.
> 
> I think I can write the apostrophing algorithm for Catalan.

How can such a language-dependent processing be integrated in this simple line:

   printf (_("%s greets you!"), argv[1]);

In an abstract point of view, _(...) needs to return a function that can
analyse its argument, instead of a string. But translators are most often
not programmers, so the maximum you can provide is a set of language-dependent
format string directives, which they can choose from.

A similar thing is done for Farsi: The translator can write "%Id" instead of
"%d" if she wants 'printf' to use the Arabic digits.

So what we need is extensibility of 'printf'. In Common Lisp one can write
an entire function name to be called in a format string. In C, we don't have
this, but at least on glibc systems, functions can be registered for use in
'printf', through 'register_printf_function'.

If you can write a library of language-dependent string processing functions
for Catalan, I can do so for French and German, and Paul Eggert for American.
These libraries can be part of GNU gettext and installed as a shared library
each. Then we need some code which loads the appropriate shared library at
program startup and calls 'register_printf_function'. The format string
that the translator would then write is

       "%|%1$/en_prefix/|%1$s et saluda!"

The %|...| is a section that shall disappear on non-glibc systems; inside
this section, %1$/en_prefix/ looks at its argument and whether it starts
with a vowel or not. en_prefix is one of the functions from your library.

Do you like the idea?

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]