string - Is there a system for internationalizing C++ streams? -
string - Is there a system for internationalizing C++ streams? -
i'm looking how internationalize c++ projects, , didn't take me long wonder how 1 handles translation of streamed text that's interspersed non-string values. page i've found far mentions this c++ fqa page, though page unfortunately isn't interested in offering solutions. there's this boost mailing list thread 2000 doesn't appear go anywhere.
as example, c-style printf
statement:
printf("there %d lines in '%s'.", numlines, filename);
it's trivial wrap entire message in sort of translation function, such gettext's various functions, , allow text , nonliteral components moved around needed. if have access posix version of printf
(or other library offering improvements printf
format), can arrange values in different order needed.
however, equivalent c++ stream-based statement:
std::cout << "there " << numlines << "lines in '" << filename << "'.";
i have yet find way mark entire message translation. wrap each string in appropriate functions, requires translator know these 3 strings part of 1 message, , appears between them. additionally, @ to the lowest degree i18n solutions need told other occurrences of same string literal distinct, languages content of literal changes based on context. , forget situations you'd have rearrange non-string-literal values.
so question is, there internationalization solution out there supports utilize of streaming operations, or there printf
-style solutions concerns raised?
boost.format can help:
cout << boost::format("there %d lines in '%s'.") % numlines % filename;
or
cout << boost::format("there %1% lines in '%2%'.") % numlines % filename;
c++ string internationalization
Comments
Post a Comment