[C++] marking keywords for use with xgettext
So.. in C, marking strings with keywords for use with xgettext is pretty straightforward, putting the marks around the quotes, and I've done it with a C program.
printf (_("Not concerned with %s any %d vars and only using %s one mark\n"), var1, var2, var3); I had trouble finding examples of how to mark keywords around cout statements. For example: cout "some" << vars1 << "between" << "vars2" << "and more" << vars3 << endl; I haven't tried to see what would happen yet if I just put a mark at the beginning and the end of that line, but I have a feeling that wouldn't get me the desired result. I wanted to hear some opinions on it. Does anyone recommend using a library other than gettext for adding support for translations to C++ programs? Is there any good reason I shouldn't consider using something like tinyformat for the C++ program I'm working in? If anyone knows of a C++ program that already uses gettext, please tell me about it and I can just look to see how it's done. Thanks... |
Luckily, you can use printf in your C++ program, too.
|
That works in most cases, but I get this warning when using a String type
Code:
hldig.cc:418:74: warning: format ‘%s’ expects argument of type ‘char*’, but argument 2 has type ‘String*’ [-Wformat=] |
Code:
minimalFile.c_str() |
If you want to have a program that is easy to translate to different languages, I very much recommend you to have one single string per sentence. The printf() format is very good for it. The reason is that in another language the order of the parameters may be different and the translators will have much harder work if they can't arrange them as they need.
|
I tried `minimalFile.c_str()` but got the error
Quote:
I did a search on that error and found mostly Arduino-related posts about it. I'm not experienced with C++, my background is mostly in C. The C++ code base I'm working on is pretty old, updated hardly at all since 2004; it's a fork of ht://Dig. Quote:
|
(You should find out where this 'String' comes from (ie: which header file), and what methods does it have.)
|
I like to use boost::format on c++ formating strings http://www.boost.org/doc/libs/1_66_0...oc/format.html
|
All times are GMT -5. The time now is 06:38 AM. |