Boost logo

Boost :

From: Rainer Deyke (rdeyke_at_[hidden])
Date: 2023-02-07 16:20:09


On 07.02.23 15:28, René Ferdinand Rivera Morell via Boost wrote:
> On Tue, Feb 7, 2023 at 7:29 AM Rainer Deyke via Boost
> <boost_at_[hidden]> wrote:
>>
>> Reservation 1: The plural problem
>> ---------------------------------
>>
>> One fundamental applications of a text templating language is to format
>> a user-visible text string with values substituted in, like the following:
>>
>> "Found %d files and %d directories."
>>
> [snip]
>
> The way that I'm familiar with to solve such problems in general is to
> properly localize your strings. Localization is not just for language
> but for gender and plurality. And the usual way to do localization is
> to provide whole alternate strings for the messages. Which is
> something that would happen outside of the template itself. As it
> would mean reading from a database of alternate strings.

If you read my full post, you will see that I have explicitly addressed
and rejected that option. The problem is that it doesn't scale. In the
above example, I would need four possibilities for English:

   "Found %d files and %d directories."
   "Found 1 file and %d directories."
   "Found %d files and 1 directory."
   "Found 1 file and 1 directory."

Each additional variable doubles the number of strings I need, so at
eight variables I am up to 256 strings, at which point I would
definitely write a script to generate the strings. And that's just for
English. Arabic has a total of 6 forms I might use, so for 8 variables
I need 1679616 different strings. I don't even want to keep that many
strings in RAM, let alone write them by hand.

-- 
Rainer Deyke (rainerd_at_[hidden])

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk