gettext-rs icon indicating copy to clipboard operation
gettext-rs copied to clipboard

d*gettext doesn't allow domain to be NULL

Open Minoru opened this issue 4 years ago • 1 comments

According to the manpage (emphasis mine):

The domain name is used to determine the message catalog where the translation is looked up; it must be a non-empty string. For the gettext function, it is specified through a preceding textdomain call. For the dgettext and dcgettext functions, it is passed as the domainname argument; if this argument is NULL, the domain name specified through a preceding textdomain call is used instead.

Meanwhile, gettext-rs expects Into<String> for domainname.

This isn't much of a problem for dgettext, because dgettext(NULL, msg) is equivalent to gettext(msg). However, there is no cgettext, so dcgettext must provide this capability.

This brings us back to #44: making the domainname an Option will hurt ergonomics IMHO, and this time, we can't weasel out of it by providing separate functions (or can we?)

Minoru avatar Mar 07 '21 00:03 Minoru

I wonder if Into<Option<Into<String>>> will work, i.e. will it accept None and "hello" and String::from("hello")? I don't have time to check it right now though; just writing this down.

Minoru avatar May 11 '21 15:05 Minoru