Re: parameterized translation strings; what is the solution?



Paul Davis wrote:
I don't think it is entirely true
that it isn't typesafe, by the way. I mean, there aren't (can't be)
proper type checks, of course, but e.g. newer versions gcc/g++ will in
fact issue a warning if there is a mismatch between the format and the
arguments.


A purist would say, "Never, ever use a function with variable argument lists.
Of course they would.

I sometimes takes the purist view myself, and certainly won't use variable argument lists without thinking hard about what I'm doing. But, sometimes when you work on real software, you have to forget about writing code that's "right" in every way, and concentrate on writing code that actually works.
Any variable arguments function is not typesafe. As you said yourself,
there can't be any type checks at compile time - hence, no type
safety. gcc/g++ will indeed warn about printf formats because it has
explicit knowledge about them. Remember that the printf/scanf family
of functions with their variable arguments are a large source of
errors in pure C. They're fertile ground for buffer overruns and other
Bad Things (TM). This is probably what motivated the compiler guys to
make special exceptions for specific functions.
Indeed.

Fortunately, they've done the job rather well, so as an application programmer, you no longer have to worry so much about the issues you mention.
I'd still recommend using one of the C++ string libraries to do your
composition.
The question is, do they offer the flexibility required to provide texts that can be correctly translated in all cases? Like the original poster said, the standard lib classes certainly won't. You have to split up your texts into separate strings, and that's quite likely to confuse the people translating the texts (as I should now, since I've actually tried sending off "gettext" source files to professional translators.) And then there's the issue of parameter order. Remember that a correct translation sometimes requires numeric values etc to be swapped, and the printf format actually allows you to do this process (though admittedly, that's another job that may seem somewhat strange to the translators.)

Another problem mentioned earlier was that none of the "other" C++ libs seem to be even de facto standards, and relying on non-standard 3rd party libs always comes with issues of its own.
Paul
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list




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