Hello, 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: http://www.gnu.org/software/autoconf/manual/gettext/MO-Files.html (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: http://lists.gnu.org/archive/html/grub-devel/2008-12/msg00030.html 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? * GRUB2 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 passed. 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 received 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 different. Would someone do it in a different way? Which way? Thanks, -- Carles Pina i Estany GPG id: 0x17756391 http://pinux.info _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel