FreeSlave / mofile

D library for parsing .mo files and getting translated messages
Boost Software License 1.0
8 stars 1 forks source link

Implementing opcall & overload #1

Closed trikko closed 6 years ago

trikko commented 6 years ago

OpCall:

MoFile moFile("ru.mo");
string s = moFile("hello, world");

Overload, why not (maybe for opcall syntax only?):

string gettext(string msgid, string msgid_plural = "", int n = 2) pure const 

// Instead of:
string ngettext(string msgid, string msgid_plural, int n) pure const
FreeSlave commented 6 years ago

xgettext utility should be able to find certain symbols to create .pot file from source file. By default these symbols are gettext and ngettext. Surely It can be changed via xgettext parameters, but using opCall means that project's author will need to find all MoFile instances names and pass them to xgettext. Not convenient at all.

FreeSlave commented 6 years ago

As for overload, xgettext seems to require different symbols to distinguish between simple translation and translation that considers plural forms.

E.g. with this file

translate("Hello, world");
translate("File", "Files", 4);

and xgettext path-to-file --keyword=translate:1 --keyword=translate:1,2

It does not produce template for plural form of Files

FreeSlave commented 6 years ago

I found out that xgettext can support overloads too https://www.gnu.org/software/gettext/manual/html_node/xgettext-Invocation.html (overloaded function calls in C++)

xgettext --keyword=translate:1 --keyword=translate:1,2,3t

I'm still not sure if it's really needed in the library. I would like to stick to xgettext defaults. Those who needs such kind of overload can make a wrapper and they will need to pass additional options to xgettext anyway.

FreeSlave commented 6 years ago

Closing. I hope my explanation on why the proposed changes are not desirable is clear.