Boost logo

Boost :

From: rogeeff (rogeeff_at_[hidden])
Date: 2001-12-20 14:57:23


--- In boost_at_y..., Karl Nelson <kenelson_at_e...> wrote:
> > Why not like this:
> >
> > BOOST_START_FORMAT_DEFINITION( classic_date_format, 3
(int,int,int))
> > arg1 << '-' << arg2 << '-' << arg3
> > BOOST_END_FORMAT_DEFINITION
> >
> > BOOST_START_FORMAT_DEFINITION( us_date_format, 3 (int,int,int))
> > arg2 << '/' << arg1 << '/' << arg1
> > BOOST_END_FORMAT_DEFINITION
> >
> > BOOST_START_FORMAT_DEFINITION( long_date_format, 3 (int,int,int))
> > day_of_week( arg1, arg2, arg3 )
> > << ' ' << arg2 << '/' << arg1 << '/' << arg1
> > BOOST_END_FORMAT_DEFINITION
>
> So this solves date, but how about every other language problem
> which is likely to occur. Many languages don't have the same
> word ordering that as English. You can't possibly make macros
> to cover all of them.

You would need only 2 macro BOOST_START_FORMAT_DEFINITION,
BOOST_END_FORMAT_DEFINITION. Everything else between brakets.

>
> Look over http://www.iro.umontreal.ca/contrib/po/HTML/gettext.html
> to see what other languages do and thus why C++ should provide
> something similar.
>
> printf (gettext ("String `%s' has %d characters\n"), s, strlen (s));
>
> printf ("%2$d Zeichen lang ist die Zeichenkette `%1$s'", s, strlen
(s));
>
>
> Considering the string is most likely provided by outside
translation
> firm who knows nothing about your code how would your approach
handle
> the above?
>

As far as I undefstand in you example you propose:

1. Have a resource storage in a form:
FORMAT_ID | FORMAT_TEXT
1 | blah blah blah
2 | blah blah blah
... | blah blah blah
236 | String `%s' has %d characters\n
...

2. You will need 1 storage per language.
3. You will need library that will access that storage in runtime to
get a message text by message id.
4. Usage will look like this:
     
printf( get_format( 236 ), s, strlen (s));

---------------------------------------------------------------

Now what an alternative:
1. Have a header file in a form

START(format1) blah blah blah END
START(format2) blah blah blah END
          ...
START(format236) "String " << arg1 << " has " << strlen(arg1) << "
characters\n " END
         ...

2. You will need 1 version of a header per language.
3. You will need include this header where needed
4. Usage will look like this:

std::cout << format236( s );
 
>
> Compile time translation means providing seperate binaries for
> i18n programs. This to me is very bad.
>

Now if you wish to be able to change a language in runtime, you can
provide a format_message<format_id>( args ) interface.

[...]
>
> --Karl

Gennadiy.


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