gettext makes supporting multiple languages translations in ki18n impossible

Albert Astals Cid aacid at kde.org
Sun Jul 29 18:31:35 BST 2018


I have just realized that gettext has no way of differentiating a translation that is the same of the original over a translation that doesn't exist.

That is, 
  char *gettext (const char *__msgid)

Will return "foo" for the message "foo" in both cases, when the translation of "foo" to the target language is "foo" and when there is no translation in the mo catalog file for that language.

Because of this ki18n makes the assumption of "If translation is the same as original message, that means the translation was not found".

Let's say I undertood Spanish and hindi and i setup my languages as such.

When asking for the translation of "Hardware" (for which there is no word in Spanish other than "Hardware") i would get the hindi word, because ki18n would think that the returned "Hardware" for the Spanish translation means that there's no translation at all and thus i should get the Hindi version before defaulting to the English word.

For me it would be "sort of ok" since i do understand Hindi, but it would really show up as a weird thing in something that i know is 100% translated to Spanish.

Ideally one would be able to query gettext about whether the translation exists or not (basically having an option to return nullptr in the above function or similar), but I have not been able to find any such functionality in glibc/libintl itself or in any other library out there.

I know this is mostly a vague complaint, but it would be great if someone suggested a way to fix/workaround this other than trying to get glibc/lintl to add support for this :D

Cheers,
  Albert




More information about the Kde-frameworks-devel mailing list