Re: parameterized translation strings; what is the solution?



On 5/27/07, Paul Elliott <pelliott io com> 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?
--
Paul Elliott                       1(512)837-1096
pelliott io com                    PMB 181, 11900 Metric Blvd Suite J
http://www.io.com/~pelliott/pme/   Austin TX 78758-3117

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list


Note that the compose library is (I believe) a header-only,
single-file library, so it would be quite easy to simply include it in
the source code of your project.  In any case, since it's a
header-only library, it would only be a build-time dependency, so
users wouldn't need it 'installed', so the distribution issue isn't as
big of a deal.  Otherwise, boost::format was mentioned and is also a
good choice.

--
jonner



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