site  contact  subhomenews

Non-English support in initrd

January 02, 2019 — BarryK

In the very early days of creating EasyOS, a couple of years ago, I designed the scripts in the initrd to use gettext, and compiled an old version of gettext statically. Then, forgot about it.

Until recently. Lutz (L18L in the Puppy Forum) is one of our experts at translation, and currently maintains the MoManager translation tool, used in Puppy and EasyOS. Lutz took a look at language translation in the initrd, found that gettext did not work, so implemented a different solution, using technosaurus's "t12s" method:

http://murga-linux.com/puppy/viewtopic.php?t=114976

I have recompiled gettext, very old version, 0.10.40, statically linked with musl, and it works. This is done in OE:

https://github.com/bkauler/oe-qky-src/tree/master/quirky/meta-quirky/recipes-quirky/gettext0-static

The init script in the initrd now has this code to get translation working, at line 368:

export wkgLANG="$(grep '^LANG=' /mnt/${WKG_DEV}/${WKG_DIR}.session/etc/profile 2>/dev/null | cut -f 2 -d '=')"
if [ "$wkgLANG" ];then #190101
#note, /usr/sbin/quicksetup makes sure a pre-existing 'easyinitrd.mo' is copied-up to .session
export TEXTDOMAINDIR=/mnt/${WKG_DEV}/${WKG_DIR}.session/usr/share/locale
export I18NPATH=/mnt/${WKG_DEV}/${WKG_DIR}.session/usr/lib/locale
#L18L: need to load a console font...
case "${wkgLANG%_*}" in
el|ru|uk|be|sr|tg|os|ba|ce|cv)
zcat /lib/consolefonts/LatGrkCyr-8x16.psfu.gz | loadfont
;;
esac
else
export wkgLANG=C
fi

As soon as the working-partition is mounted, gettext is able to access the locale setting, see variables "TEXTDOMAINDIR" and "I18NPATH".

The fundamental problem with this method is that translation only kicks in after the working-partition is mounted. Earlier text strings to the display remain in English, as does the syslinux and refind boot menus.

So, I am seriously considering abandoning this method entirely. Instead, will do sed translations of the strings, including boot menus, and rebuild the initrd. This is a complete translation of everything, right from initial bootup menu.

Anyway, you guys can help me. I have a easyinitrd.pot file, and anyone proficient in a non-English lanugage could help by filling in the translations. There is a easyinitrd.pot file here:

http://murga-linux.com/puppy/viewtopic.php?p=1014409#1014409

The fields can be translated, for example, this google de translation:

#: init:376
msgid "One-time only operation, creating a snapshot of EasyOS"
msgstr "Einmaliger Vorgang, der eine Momentaufnahme von EasyOS erstellt"

The file can then be saved as, say, de.po, and uploaded to the forum. Two-letter language translations only please, I would rather not have to deal with regional dialects. So de.po only, generic German. I know that will be a compromise with, say, Brazilian Spanish as it differs from Spanish as written in Spain, but the strings are simple and a generic translation agreeable to everyone I am sure can be found.

Although I am considering abandoning the gettext method, the string translations are still needed, if I implement a sed translation method.  Help most welcome! 

Tags: easy