site  contact  subhomenews

Syslinux and reFind boot-manager translation

January 06, 2019 — BarryK

EasyOS ships as an image file that may be written to a USB Flash stick, or even an SSD, or the contents extracted and manually installed into a SSD/HD.

The image file contains two boot manager, Syslinux for booting on traditional BIOS PCs, and reFind for booting on UEFI PCs. These boot managers provide a menu, which is in English.

It is probably not a big deal, as most non-English computer users probably understand some simple English words. However, for the complete translation experience, translation of the boot managers is now implemented.

initrd and gettext

I posted yesterday about implementation of the initrd:

This is done using gettext. The initrd needs to have support for the language in it. When there is a change of locale, /usr/lib/locale/<lang>, for example /usr/lib/locale/de_DE.utf8, is copied into the initrd, however, /usr/lib/locale/de_DE.utf8/LC_COLLATE and LC_CTYPE are left out due to their sizes.

Also, /usr/share/locale/<language>/LC_MESSAGES/, for example /usr/share/locale/de/LC_MESSAGES/, if it exists, is copied into the initrd.

Then, "INIT_LANG='de_DE.UTF-8'" is appended to /BOOT_SPECS in the initrd, and the initrd is good-to-go, translated.

This is MoManager-friendly. When MoManager is run (in the Utility menu), there is /usr/share/doc/nls/easyinitrd/easyinitrd.pot, and an existing translation will be found at /usr/share/locale/<language>/LC_MESSAGES/ Anyone will be welcome to either do a new translation or tweak the existing one. You need to run MoManager to see how to do this, it is quite easy, much easier to just do it rather than me try to explain how.

Boot managers and SSS

I elaborated on translation of the initrd above, to emphasize that it is different from how the boot manager menus are translated. The menus are translated using SSS (Simple String Replacement).

There is a file, /usr/share/sss/boot_strings/boot_strings. Just a text file, and inside you will find lines like this:

s%Commandline only, do not start X%%

In a text editor, insert translations, like this for German:

s%Commandline only, do not start X%Nur Befehlszeile, starten Sie X nicht%

And save the translated file as /usr/share/sss/boot_strings/

That's it, done. Whenever there is a locale change, the translation file will be applied to the boot manager menus (files syslinux.cfg and refind.conf) in the boot-partition.

You can also use MoManager to manage SSS translations. Which really just does the same thing, opens the file in a text editor.

Some technical details:

/usr/sbin/quicksetup is where locale change is made. /usr/sbin/chooselocale is a symlink to quicksetup.

When locale is changed, then /usr/sbin/lang2initrd is called, which asks if you want to translate the initrd and boot-manager menus in the boot-partition, If yes, then calls /usr/sbin/fixinitrd and /usr/sbin/fixboot -- actually, both of those are symlinks into /usr/sbin/fixdesk.

In the case of fixboot, if a boot_strings.<language> file exists,then it is applied to the boot-manager menus.

Tags: easy