solbu / hldig

hl://Dig is a fork of ht://Dig, a web indexing and searching system for a small domain or intranet
https://solbu.github.io/hldig/
Other
18 stars 21 forks source link

Adding support for translating the output messages #52

Open andy5995 opened 6 years ago

andy5995 commented 6 years ago

Although I've added some support for translating the output messages using gettext, I haven't completed the process yet. Now I wonder if a different method should be used. I have used used gettext before with a C program, but not a C++ program. I wonder if there are alternate solutions that should be considered. Does anyone have suggestions about this?

I've done some searching, but haven't found answers yet to how this would be done

Using gettext with a C program, a string would be marked like this:

printf (_("I am %d years old and my zipcode is %d\n"), age, zipcode);

But that wouldn't work with a C++ cout string.

cout << "I am " << age << " years old and my zipcode is " << zipcode;

There would have to be marks around each string within the quotation marks... or would there? I couldn't find any info about it that made sense.

Or maybe implementing tinyformat.h should be an option.

tinyformat.h is a type safe printf replacement library in a single C++ header file. If you've ever wanted printf("%s", s) to just work regardless of the type of s, tinyformat might be for you.

andy5995 commented 6 years ago

Some additional info on this LQ forum thread:

[C++] marking keywords for use with xgettext