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

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

Re: Proper way to handle message strings with more than one plural item?


From: Bruno Haible
Subject: Re: Proper way to handle message strings with more than one plural item?
Date: Sat, 12 Apr 2008 12:28:46 +0200
User-agent: KMail/1.5.4

Hello,

Aaron Gaudio wrote:
> Hello, I hope this is the right place to direct this question

Yes it is.

> I'm new to using the gettext family of functions, and it's not clear to
> me if there is an accepted method of translating a single message that
> contains more than one numeric item, and so may require pluralization
> rules for more than one item at a time.
> 
> For instance,
> 
> "From %1$d day(s) to %2$d week(s)."
> 
> The first parameter may be 1-6 days and the second parameter may be 1-N
> weeks. In English, clearly it is desirable to get results like the
> following:
> 
> "From 1 day to 1 week."
> "From 1 day to 3 weeks."
> "From 2 days to 3 weeks."
> "From 2 days to 1 week."
> 
> And obviously in other languages with more complex rules the
> possibilities grow even faster.
> 
> I could break the string up, but that might lose some context for the
> translator, and may also be invalid in some languages that might need to
> reverse the order of phrases.
> 
> So, since ngettext seems to only allow a single plural variable, is
> there a "preferred" path for what I'd like to do?

This case is not well supported by the gettext tools, because in some
languages the translators would have to provide 4*4 = 16 different strings.

As discussed in the thread [1], simply splitting the message is not a good
option.

I would try to reformulate the string so that it can be split, and add
translator comments to indicate the grammatical dependency. Like this:
  
  ngettext("The old duration was %u days," ...);

  /* TRANSLATORS: This sentence is a continuation of "The old duration was ..."
     above.  */
  ngettext(" and the new one is %u weeks.");

Bruno


[1] http://lists.gnu.org/archive/html/bug-gnu-utils/2007-06/msg00003.html





reply via email to

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