Re: parameterized translation strings; what is the solution?



Paul Elliott wrote:
How are parameterized translation strings commonly handled?

Suppose I need to create a string like:

"file %1 failed to open", where %1 exists at runtime, but I need to
create it in a way that can be internationalized.

If I do something like this

str = _("file ") + filename + _(" failed to open");

The string to be translated is broken into pieces and the translators
can't see what is going on. Besides different languages have different
word order. You can't necessarily hack tranlated phrases from a
different language together in the same way that you do in the native
language. Some things need to be translated as a whole.

Also there is UTF-8 and unicode.

Bjarne Stroustrup properly points out that sprintf and format
are not typesafe.

So what is the solution?

Gtkmm documentation recommends the compose library, but
that seems to be included in almost no Linux distributions,
so that can not be commonly used.

What is the solution that is used everyday in the real world?

Use boost::format

Cheers,
Tim




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