Boost logo

Boost :

Subject: Re: [boost] Boost.Locale and the standard "message" facet
From: Vicente BOTET (vicente.botet_at_[hidden])
Date: 2011-05-04 13:06:05


> Message du 03/05/11 07:56
> De : "Artyom"
> A : boost_at_[hidden]
> Copie à :
> Objet : Re: [boost] Boost.Locale and the standard "message" facet
>
> > From: Vicente BOTET
> > >
> > > If "File was opened {1} day ago" is not in dictionary that
> > > it would be used as no Hebrew alternative provided, also
> > > it would have 2 plural forms (as English) instead of
> > > 3 (in Hebrew).
> >
> >
> > I insists, could you show the catalog associated to this
> > translation in English and in Hebrew? I'm sure
> > I'm missing something and I don't reach to see what.
>
>
> The hebrew catalog looks like
>
> he.po
>
> # translation of foo.po to Hebrew
> "Project-Id-Version: foo\n"
> "PO-Revision-Date: 2008-06-07 15:04+0300\n"
> "Last-Translator: Artyom \n"
> "Language-Team: Hebrew \n"
> "MIME-Version: 1.0\n"
> "Content-Type: text/plain; charset=UTF-8\n"
> "Content-Transfer-Encoding: 8bit\n"
> "Plural-Forms: nplurals=3; plural= n==1 ? 0 : (n == 2 ? 1 : 2);\n"
> "X-Generator: KBabel 1.11.4\n"
>
> msgid "File was opened {1} day ago"
> msgid_plural "File was opened {1} days ago"
> msgstr[0] "Kovetz niftah lifney yom {1}"
> msgstr[1] "Kovetz niftah lifney yomaim"
> msgstr[2] "Kovetz niftah lifney {2} yamim"
>
>
> The English is the original string.
>
> In Japanese or Chinese (with one form) it would be
>
> ja.po
> ...
> "Plural-Forms: nplurals=1; plural=0;\n"
> ...
> msgid "File was opened {1} day ago"
> msgid_plural "File was opened {1} days ago"
> msgstr[0] "Some Japanese text {1} some Japanese text"
> ...
>
> The "Plural-Forms:" section of meta record describes
> the format of plural forms: their number and equation
> in C that calculates it from parameter, the facet
> that loads catalog parses the C equation and know
> how to calculate it.

Thanks. This clarify a lot of things to me. I don't know if you have some example of catalogs already in the documentation, but if not I'm sure that others will appreciate them.

I don't know why I believed that the plural handling was managed by the library.

> > format(translate("Format date with H-M-S","{1}, {2}, {3}"))
> > % format(translate("Format date with H-M-S","{1} hour","{1} hours"))
> > % format(translate("Format date with H-M-S","{1} minute","{1} minutes"))
> > % format(translate("Format date with H-M-S","{1} second","{1} seconds"))

I guess the h, m, s are missing here and it seems to me that the use of parenthesis is needed.

format(translate("Format date with H-M-S","{1}, {2}, {3}"))
% (format(translate("Format date with H-M-S","{1} hour","{1} hours"), h) % h)
% (format(translate("Format date with H-M-S","{1} minute","{1} minutes"), m) % m)
% (format(translate("Format date with H-M-S","{1} second","{1} seconds"), s) % s)

could you confirm?

> > The single problem I see which character use to split the string. Maybe %
> >could be used
> >
> >
> > translate("%1 hours%,% %2 minutes%,% %3 seconds") % h % m % s
> >
>
> Not sure about it how exactly you want to do this? Would
>
> format(translate("Format date with H-M-S",
> "[{1} hour|{1} hours], [{2} minute|{2} minutes], [{3} second|{3} seconds]",
> h,m,s)) %h % m % s
>
> Is better? I don't know... Need to think about, because
> there may be more corner cases that I don't see yet.

I don't like the redundant parameters, one given to the translate function and then to format. A part from that point it merits some more deep analysis. Is this redundancy needed currently with only one parameter?

> > > The C++0x had deprecated std::auto_ptr that everybody
> > > uses and had given std::unique_ptr.
> > >
> > > You are suggesting to enforce bad design to
> > > good facet just because it exists and nobody
> > > uses it?
> > >
> > > I disagree. This std::messages facet should be
> > > deprecated or even removed.
> >
> > No. I'm just telling that if you have valid arguments
> > it will be better to deprecate one and add one that
> > is better. But having two catalogs is not good.
>
> Yes I recommend to deprecate.
>
> > For example if I want to make Chrorno internationalizable
> > I can just use Std facet message until there is a better facet.
>
> And it would work only on... Linux
>
> - gcc supports locales only on Linux
> - MSVC does not support messages at all.
>
> That is the sad reality.

You have added a new facet on boost using strings, that you implement completely. The same can be done with integers and follow the standard as much as possible independently of whether std::message is supported on windows or not. But I'm not requesting you to do it.

I suspect, that if I want to make Boost.Chrono internationalizable I have no choice. I will need to use your library until something standard is working on a portable way.

Thanks for all the valuable informations.

Best,
Vicente


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