[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Carles Pina i Estany
Subject: gettext
Date: Tue, 13 Jan 2009 23:11:56 +0100
User-agent: Mutt/1.5.18 (2008-05-17)


I was thinking to implement some kind of internalization in Grub2. We
discussed some months ago, but now I have been playing with something
and thinking a bit more how to do it.

I have done a "draft" program (working, not shareable -needs some
clenaup-, in standalone C) that getting a .mo file and string translates
the string.

I've based my implementation on:
(the basic one is about 200 lines)

I'm not using the gettext hash table so I safe some space (in the .mo
files and code), and Grub doesn't have so much strings to need the hash.
Also, I'm using bisection to search a bit faster. I'm using msgmft
--no-hash to not include the hash in the .mo file.

* SCRIPTS (userland)
We could add gettext support using external gettext program like I
commented here:

or we could use the Grub2 "gettext mo reader" program (already
implemented the basic version): so we would be testing our mo reader
even in userland, and have one less dependency: gettext binary (in
Debian it comes with gettext-base package).

Which are your thoughts for it?

My idea is to create in Grub2 a function called _("..."). This function
will exist in standard Grub2 and return the same string that it's

Then I would implement a module that overwrites this function and does
something like:
a) get Grub2 language variable (to decide the language)
b) open the language file and search for the string that the function
c) return the translation (or same string if could not be find)

Thing to maybe improve:
not open the .mo file everytime and read a couple of headers (just a few
fseek and fread, actually) and do it only when the variable is changed.
So I would need a hook to reopen the .mo file and load some .mo file
information when the user changes the variable or perhaps check the
previous variable value with the current one and reopen the file if it's

Would someone do it in a different way? Which way?


Carles Pina i Estany            GPG id: 0x17756391

reply via email to

[Prev in Thread] Current Thread [Next in Thread]