Le 25/03/2013 12:07, Vincent van Ravesteijn a écrit :
Yes, I think we should. On Windows, it takes around 200-250usec to get a
translated message, while on Linux you estimated it as 5usec. So, the
issue might pop up in other situations as well, even though there are no
problems on Linux.

OK.

On a side note, approximately 160-180usec is spent in setting and
unsetting the environment variables. I'd expect that this would not be
needed to do for each translation request. Removing those calls from the
Messages::get function would reduce the time to 40-50usec for each
call. I don't know right now why it is still much slower than the 5usec
on Linux.

Interesting. Now I know why gettext is slow with windows. It is environment setting that takes all the time.

This is because of the horrible API of gettext. We can need several different languages at the same time, and we cannot pass that as a parameter. Moreover, if we leave these environment variables as set, they will influence the behavior of the external processes that we run.

I am more and more tempted at use some C++ .mo file reader like
this
  https://github.com/laurent22/simple-gettext

This library amounts to less that 1000 lines of code AFAICS. We can afford to import it in our code and customize it to our needs. I just have to find a clear statement about license.

Besides reading mo files, what does the horrible gettext code buys us?

* auto detection of the OS language: Qt can do that.
* encoding conversion: we already have some iconv stuff of our own, and
  we could enforce using UTF8 in our po files if it is not yet the case.
* special handling for plural forms, context (we do our own),

All in all, I think life would be easier.

JMarc

Reply via email to