Page 1 of 3

internationalization of initrd messages at bootup

Posted: Thu 06 Oct 2011, 19:49
by L18L
Wouldn't it be nice to see messages at bootup in your language?

Not just nice but often helpful.

I have started this using frugal installation of latest wary5.1.103

Now limited to available consolefonts lat1 and lat2, but it is a start :)
________________________________________
edited 2011-10-21-14:50 CEST

Now for all European languages, Arab and Hebrew.

edited 2011-10-23-20:32 CEST
Arab and Hebrew still not possible :cry:

-------------------------------------------------------------


init script splitted:
init:

Code: Select all

#!/bin/sh
#(c) Copyright 2007 Barry Kauler, www.puppylinux.com
#2007 GPL licence v2 (/usr/share/doc/legal/gpl-2.0.txt)
#Aug 2007, init script in initramfs, for puppy v2.20, Sept: v3.00, Oct: v3.01
...
...
...
#/bin/hotplug2stdout_notimeout > /tmp/pup_event_uevents_initrd &

#translate rest of splitted script (= init2) to boot param plang #L18L
[ $plang -a -f /boot_msg/${plang} ] &&  mv /init2 /trans && sed -f /boot_msg/${plang} /trans > /init2 && rm /trans
. /init2
translation file see next post

EDIT: screenshots some posts down

internationalization of progress messages at bootup

Posted: Thu 06 Oct 2011, 19:52
by L18L
Translation is done by stream editor sed, delimiter is #

The following file for translation to German (de) is placed into initrd/boot_msg/de

Post other translations here please.

Code: Select all

 #English#translation#
s#'save file' filesystem check, please wait...#'save file' Dateisystem-Check, bitte warten...#g
s#'${1}' filesystem check, please wait...#'${1}' Dateisystem-Check, bitte warten...#g
s#ERROR: Windows NTFS hibernated partition, cannot mount#FEHLER: Windows NTFS winterschlafende Partition, kann nicht einhängen#g
s#32mdone#32mgetan#g
s#failed#fehlgeschlagen#g
s#Dumping last lines of /tmp/bootinit.log...#Zeige letzte Zeilen vom /tmp/bootinit.log...#g
s#Dumping last lines of kernel log...#Zeige letzte Zeilen vom kernel log...#g
s#Pausing for 60 seconds...#Pausiere für 60 Sekunden...#g
s#PAUSE 5SEC: tried to mount /dev/${ONEDEV}, ${ONEFS} f.s.#PAUSE 5SEC: versuchte Dateisysteme /dev/${ONEDEV}, ${ONEFS} einzuhängen.#g
s#pausing#pausiere#g
s#RETRY FAILED: mounting /dev/${ONEDEV}, ${ONEFS} f.s.#2.VERSUCH FEHLSCHLAG: einhängen der /dev/${ONEDEV}, ${ONEFS} Dateisysteme.#g
s#Bypass looking for vmlinuz on $ONEDEV#Umgehe nachsehen, ob vmlinuz auf $ONEDEV ist#g
s#Loading '${PKEYS}' keyboard layout...#Lade '${PKEYS}' Tastatur-Layout...#g
s#Loading drivers needed to access disk drives#Lade Treiber für Zugriff auf Plattenlaufwerke#g
s#Searching for Puppy files...#Suche nach Puppy-Dateien...#g
s#${DROPOUT} not found. Dropping out to initial-ramdisk console...#${DROPOUT} nicht gefunden. Falle zurück auf initiale ramdisk Konsole...#g
s#Type a number to choose which personal file to use:#Tipp eine Ziffer zur Auswahl der zu verwendenden persönlichen Datei:#g
s#0  none#0  keine#g
s#Loading personal file $PUPSAVEFILE ($PUPSAVEDEV)...#Lade persönliche Datei $PUPSAVEFILE ($PUPSAVEDEV)...#g
s#Mounting encrypted $PUPSAVEFILE...#Hänge verschlüsselte Datei $PUPSAVEFILE ein...#g
s#Increasing $PUPSAVEFILE by $KILOBIG Kbytes, please wait...#Vergrößere $PUPSAVEFILE um $KILOBIG Kbytes, bitte warten...#g
s#NOTICE: As you type your password nothing will be displayed on the#HINWEIS: Bei der Eingabe des Paßworts wird nichts auf dem Bildschirm angezeigt #g
s#screen for absolute security. Just type it in then press ENTER key...#zur absoluten Sicherheit. Nur eingeben und dann die Enter-Taste drücken...#g
s#Password:#Paßwort:#g
s#...continuing with loading $PUPSAVEFILE...#...lade $PUPSAVEFILE weiter...#g
s#...successfully mounted#...erfolgreich eingehängt#g
s#Can't mount file, press ENTER key to try again, or#Kann Datei nicht einhängen, Enter-Taste für noch einen Versuch oder#g
s#any other char then ENTER for f.s. check then try again, or#irgendeine und dann Enter-Taste für Dateisystem-Check und noch einen Versuch, oder#g
s#for developers type 'quit' to drop out to console:#für Entwickler: tipp 'quit' für Konsole:#g
s#Increasing $PUPSAVEFILE by $KILOBIG Kbytes, please wait...#Vergrößere $PUPSAVEFILE um $KILOBIG Kbytes, bitte warten...#g
s#This save-file was last used with version $OLDDISTRO_VERSION of Puppy#Diese Sicherungsdatei wurde zuletzt benutzt mit Version $OLDDISTRO_VERSION von Puppy#g
s#Hit the ENTER key only if it is okay to upgrade this file, or to#Nur fie Enter-Taste drücken, wenn es OK ist, diese Date upzugraden, oder #g
s#not use it and boot up in RAM only type any other printable character.#um sie nicht zu benutzen, irgendeine druckbare Taste und dann die Enter-Taste.#g
s#ENTER only to upgrade:#Nur die Enter-Taste zum Upgrade:#g
s#Backing off, not using save-file, booting in RAM only, PUPMODE=5...#Ohne alte Daten, save-file nicht benutzt, booting in RAM only, PUPMODE=5...#g
s#The main Puppy file '${basepupsfs}' is being loaded off the optical disc.#Die Puppy-Hauptdatei '${basepupsfs}' wird jetzt vom optischen Medium geladen.#g
s#Very slow! Type ENTER key only to copy it to the same partition as the save-file#Sehr langsam! Nur die Enter-Taste drücken zum Kopieren auf dieselbe Partition wie die Sicherungsdatei#g
s#then on next boot it will load fast. Type any printable char not to copy it.#dann wird beim nächsten Neustart schneller geladen werden. Irgendein druckbares Zeichen zum Nichtkopieren.#g
s#ENTER key only to copy:#Nur Enter-Taste zum Kopieren:#g
s#'${basepupsfs}' now copying to hard drive (but only available next boot)...#'${basepupsfs}' wird jetzt auf die Festplatte kopiert (aber erst beim nächsten Neustart verfügbar)...#g
s#Folder $ONEFOLDER marked bad.#Folder $ONEFOLDER als schlecht markiert.#g
s#Loading folder $ONEFOLDER from CD/DVD...#Lade Verzeichnis $ONEFOLDER von CD/DVD...#g
s#RAM full#RAM voll#g
s#copying to ram#kopiere ins RAM#g
s#Loading the '${basepupsfs}' main file...#Lade die '${basepupsfs}' Hauptdatei...#g
s#Setting up the layered filesystem...#Richte das überlagernde Dateisystem ein...#g
s#Version update, restoring 'official' files, please wait...#Version update, restauriere 'offizielle' Dateien, bitte warten...#g
s#(with a slow CPU this may take sometime, please be patient)#(mit einer langsamen CPU kann das eine Weile dauern, bitte etwas Geduld)#g
s#to#auf#g edited: very bad:use entire phrases :cry:

Code: Select all

s#You are upgrading Puppy ${OLDstr} ${NEWPVERSION}.#Du upgradest Puppy ${OLDstr} ${NEWPVERSION}.#g
s#Overwritten old files have been moved to /tmp/versioncleanup/#Überschriebene alte Dateien sind nach /tmp/versioncleanup/ verschoben worden#g
s#After bootup please examine this directory (before shutdown) for anything#Nach dem Start examiniere bitte dieses Verzeichnis (vor dem Herunterfahren) auf alles#g
s#that you might like to recover. Pausing 30 secs so you can read this msg...#was vielleicht erhalten werden soll. 30 Sekunden Pause zum Lesen dieser Meldung...#g
s#Overlaying preconfig files...#Überlagern der preconfig-Dateien...#g
s#Performing a 'switch_root' to the layered filesystem...#Führe ein 'switch_root' auf das überlagernde Dateisystem aus...#g
s#Dropped to initramfs shell. Type 'exec switch' to continue booting Puppy.#Zur initramfs shell gefallen. Tipp 'exec switch' zum Weiterstart von Puppy.#g
s#from version $xOLDPVERSION to#von Version $xOLDPVERSION auf#g
s#This is a simulated version upgrade, which performs a file cleanup.#Dies ist ein simuliertes Version-upgrade, das eine Dateisäuberung ausführt.#g
s#This is a radical file cleanup for broken systems, could alter some settings.#Dies ist eine radikale Dateisäuberung für defekte Systeme, könnte einige Einstellungen verändern.#g
That is how this file has been created:

extracted init from itird.gz
marked 63 translatable lines by '#tr'

extract them:

grep '#tr$' init > translation
cat -n translation | cut -d '"' -f2 > tr
cat -n translation | cut -d '"' -f4 >>tr
cat -n translation | cut -d '"' -f6 >>tr

edit tr:
trimmed
delete double entries
delete empty lines
59 lines remaining

create sed file:
file=translated
echo '#English#translation#' > $file
while read LINE; do
echo "s#${LINE}#${LINE}#g" >> $file
done<tr

cp translated to boot_msg/de
edit boot_msg/de:
s#English message#German message#g

internationalization of progress messages at bootup

Posted: Fri 07 Oct 2011, 20:40
by L18L
equivalent to xgettext

Code: Select all

#!/bin/sh
# create translate template from shell script
# lines containing translatable strings have to be marked by
# Syntax to use for automatic creation of translate template
#   #tr2 -> grep tr.$ | cut -d '"' -f 2
#   example:
#    echo -n " 'save file' filesystem check, please wait..." >/dev/console #tr2
#    
#   #tr4 -> grep tr.$ | cut -d '"' -f 4
#
#   #tr6 -> grep tr.$ | cut -d '"' -f 6
#    example:
#  [ "$xOLDPVERSION" != "0.0" ] && OLDstr="from version $xOLDPVERSION to" #tr6
#####################################################

infile=init2
outfile=template1

echo -n > ${outfile}
while read LINE ; do
 case $LINE in
  *tr2) x=`echo $LINE | cut -d '"' -f 2`
        [ "$x" = "$LINE" ] && x=`echo $LINE | cut -d "'" -f 2` 
        echo $x >>  ${outfile} ;;
  *tr4) x=`echo $LINE | cut -d '"' -f 4`
        [ "$x" = "$LINE" ] && x=`echo $LINE | cut -d "'" -f 4` 
        echo $x >>  ${outfile} ;;
  *tr6) x=`echo $LINE | cut -d '"' -f 6`
        [ "$x" = "$LINE" ] && x=`echo $LINE | cut -d "'" -f 6` 
        echo $x >>  ${outfile} ;;
  *tr8) x=`echo $LINE | cut -d '"' -f 8`
        [ "$x" = "$LINE" ] && x=`echo $LINE | cut -d "'" -f 8` 
        echo $x >>  ${outfile} ;;
 esac
done < ${infile} 

sort --uniq ${outfile} >${outfile}_uniq
check ${outfile}_uniq
then create sed file (see above post)

internationalization of initrd messages at bootup

Posted: Sat 08 Oct 2011, 19:10
by L18L
And here is how it looks (was the most difficult part without photo)

internationalization of initrd messages at bootup

Posted: Sun 09 Oct 2011, 11:34
by L18L
Reviewing screenshot now...

mishmash of deutsch english in performing a 'switch_root' ....

Reason: translation of 'to'
Fix:
# OLDstr='to'

# [ "$xOLDPVERSION" != "0.0" ] && OLDstr="from version $xOLDPVERSION to"
[ "$xOLDPVERSION" != "0.0" ] && OLDstr="from version $xOLDPVERSION"

echo "You are upgrading Puppy ${OLDstr} to ${NEWPVERSION}." >/dev/console

This will cause 'to' to NOT be in the translation template :lol:
_______________________

German translation:
getan is :roll:
erledigt appeared to be better but too long (last letter in next line)
fertig will be in next version

Any suggestions for better translations ?
...Zugriff auf Plattenlaufwerke ???
Lade die 'puppy_wary...' Hauptdatei...
oder besser?:
Lade die Hauptdatei 'puppy_wary...'...

internationalization of initrd messages at bootup

Posted: Mon 10 Oct 2011, 07:35
by L18L
Barry,
I have thought uploading this could be useful too

internationalization of initrd messages at bootup

Posted: Wed 19 Oct 2011, 13:15
by L18L
Howto display UTF-8 in console?

Here is a little demo made in wary 5.2

Extract attached console_i18n_demo.tar.gz where you like to
Here is a screenshot of executing script i18n

If it does not display properly for every language you might install
ucs-fonts-target3.pet

busybox in initrd does NOT have setfont
so I could not use it where it should be used: in initrd

Anyone able to add fontset to busybox of initrd?
edited:
using loadfont now which is included in busybox of initrd (thanks Technosaurus)

Re: internationalization of initrd messages at bootup

Posted: Wed 19 Oct 2011, 14:52
by Moose On The Loose
L18L wrote:And here is how it looks (was the most difficult part without photo)
The picture brings up a couple of interesting questions:

Is "Wary" a bad word in anybodies language?

Some cultures, German is one as is English, calling someone or something a dog has a meaning. Is there anything bad about the word puppy?

The puplets like "bigdog" may have an issue in some languages too.

Re: internationalization of initrd messages at bootup

Posted: Wed 19 Oct 2011, 16:17
by L18L
Moose On The Loose wrote:Is "Wary" a bad word in anybodies language?
This word is not used in German. (but: make love not war was popular once upon a time...)
Moose On The Loose wrote:Some cultures, German is one as is English, calling someone or something a dog has a meaning. Is there anything bad about the word puppy?

Calling someone a dog can be a compliment in Bavaria
The word puppy in German is unknown
Depending on its pronountiation it is either a doll or daddy :D
So nothing bad :)

Posted: Thu 20 Oct 2011, 03:39
by technosaurus
here is the fastest/easiest method that I have found, it doesn't require bashisms or any outside shell stuff like sed/grep/cut/tr ....
but more importantly, the translation files are raw text that _any_ user can modify

here is a basic template:

Code: Select all

case $LANG in
	de*|be*|br*|dk*|es*|fi*|fr*|it*|no*|se*|sv*|pt*)
		modprobe nls_cp850
		CODEPAGE="850"
		zcat /lib/consolefonts/lat1-12.psfu.gz | loadfont
	;;
	cz*|hu*|pl*|ro*|sk*|cr*|sl*)
		modprobe nls_cp852
		modprobe nls_iso8859-2
		CODEPAGE="852"
		zcat /lib/consolefonts/lat2-12.psfu.gz | loadfont
	;;
esac
 
case $LANG in
#uncomment locales as they are added
#	de*). /etc/locale/de/init;;
#	be*). /etc/locale/be/init;;
#	br*). /etc/locale/br/init;;
#	dk*). /etc/locale/dk/init;;
#	es*). /etc/locale/es/init;;
#	fi*). /etc/locale/fi/init;;
#	fr*). /etc/locale/fr/init;;
#	it*). /etc/locale/it/init;;
#	no*). /etc/locale/no/init;;
#	se*). /etc/locale/se/init;;
#	sv*). /etc/locale/sv/init;;
#	pt*). /etc/locale/pt/init;;

#	cz*). /etc/locale/cz/init;;
#	hu*). /etc/locale/hu/init;;
#	pl*). /etc/locale/pl/init;;
#	ro*). /etc/locale/ro/init;;
#	sk*). /etc/locale/sk/init;;
#	cr*). /etc/locale/cr/init;;
#	sl*). /etc/locale/sl/init;;
	*)echo $LANG not yet supported, please help us translate >/dev/console
esac

#each file in /etc/locale/*/init will contain localized string variables like:
#  VAR1='Some translated string'
#  ...
#  VARZ='Last translated string'
#NOTE: use a variable name that makes sense for translating for the template
#  instead of VAR1='', use PERFORMING_SWITCHROOT=''

echo ${VAR1:-Default English Message Here} >/dev/console
#more code here
echo ${PERFORMING_SWITCHROOT:-Performing Switchroot} >/dev/console

internationalization of initrd messages at bootup

Posted: Thu 20 Oct 2011, 18:50
by L18L
Technosaurus,

One question about your localized string variables

Can they contain variables?
For example how would you make

Code: Select all

s#Increasing $PUPSAVEFILE by $KILOBIG Kbytes, please wait...#Vergrößere $PUPSAVEFILE um $KILOBIG Kbytes, bitte warten...#g 
Your script has given the solution for my font problem using loadfont instead of setfont now.

Code: Select all

case $plang in
 el) zcat /lib/consolefonts/LatGrkCyr-8x16.psfu.gz | loadfont # greek
  *) zcat /lib/consolefonts/LatArCyrHeb-16.psfu.gz | loadfont 
esac
Tested, it works, booted wary52 Russian (just the first 2 phrases)

That is my solution for now.

Thanks for your input :)
L

Re: internationalization of initrd messages at bootup

Posted: Thu 20 Oct 2011, 23:42
by technosaurus
L18L wrote:Technosaurus,

One question about your localized string variables

Can they contain variables?
For example how would you make

Code: Select all

s#Increasing $PUPSAVEFILE by $KILOBIG Kbytes, please wait...#Vergrößere $PUPSAVEFILE um $KILOBIG Kbytes, bitte warten...#g 
L
since they are variables, I wouldn't (there is a way, but would increase code complexity) ... instead, use multiple small variables:
echo ${INCREASING:-Increasing} $PUPSAVEFILE ${BY:-by} $KILOBIG Kbytes, ${PLSWAIT:-please wait...} >/dev/console

Perhaps a useful trick for language selection

Posted: Fri 21 Oct 2011, 02:17
by Moose On The Loose
[quote="technosaurus"]

Code: Select all

case $LANG in
#uncomment locales as they are added
#	de*). /etc/locale/de/init;;
#	be*). /etc/locale/be/init;;
#	br*). /etc/locale/br/init;;
#	dk*). /etc/locale/dk/init;;
how about:

Code: Select all

if test -e /etc/locale/${LANG}/init ; then
. /etc/locale/${LANG}/init
fi
If you make a file with the right name it gets used.
The mere addition of a file causes the new translation to happen

Posted: Fri 21 Oct 2011, 04:21
by technosaurus
i had done it like this:

[ -e /etc/locale/${LANG}/init ] && . /etc/locale/${LANG}/init

but realized that sometimes it may be something like de_DE (thus the case statement)

but now that you mentioned it, it could be

Code: Select all

[ -e /etc/locale/${LANG:0:2}/init ] && . /etc/locale/${LANG:0:2}/init

Posted: Fri 21 Oct 2011, 09:36
by BarryK
Hi guys,
This is interesting stuff. I'm a bit pre-occupied right now, but intend to come back and read this thread properly later.

One quick question. L18L, I see that you propose "plang=de", but Puppy already supports "pkeys=de" -- couldn't we just have the one, to simplify things? Perhaps "plang=de" could also imply keyboard layout is "de". Or, maybe they do need to remain separate.

internationalization of initrd messages at bootup

Posted: Fri 21 Oct 2011, 10:17
by L18L
technosaurus wrote:i had done it like this:

[ -e /etc/locale/${LANG}/init ] && . /etc/locale/${LANG}/init

but realized that sometimes it may be something like de_DE (thus the case statement)

but now that you mentioned it, it could be

Code: Select all

[ -e /etc/locale/${LANG:0:2}/init ] && . /etc/locale/${LANG:0:2}/init
replacing ${LANG:0:2}
by
`echo $LANG | cut -d '_' -f 1` (or equivalent in pure shell)
would serve 3-letters coded languages too, they exist :)

internationalization of initrd messages at bootup

Posted: Fri 21 Oct 2011, 10:55
by L18L
BarryK wrote:Hi guys,
This is interesting stuff. I'm a bit pre-occupied right now, but intend to come back and read this thread properly later.

One quick question. L18L, I see that you propose "plang=de", but Puppy already supports "pkeys=de" -- couldn't we just have the one, to simplify things? Perhaps "plang=de" could also imply keyboard layout is "de". Or, maybe they do need to remain separate.
Quick answer
plang is just the language to start with (locale not needed)
or better call it: planguage to not confuse with LANG

I am using pkeys=de-latin1 (simple de does not work for me)
Sometimes a user has to use a keyboard of another language...
And sometimes a user might want to use another language with the same keyboard...

I have been thinking about why pkeys is necessary at all at booting.
choosing one of the save files? just a number
What else?
Entering password in case of encrypted save file !
Other cases? I don't know.

Omitting pkeys as boot parameter we had just to switch keyboard layout temporarily to default en_US when asking for password...

internationalization of initrd messages at bootup

Posted: Fri 21 Oct 2011, 12:45
by L18L
Here is what I have changed in initrd to enable translation of messages

Note, the most important thing for me was to find consolefonts.

Code: Select all

 [ $plang = "el" ] && zcat /lib/consolefonts/LatGrkCyr-8x16.psfu.gz   | loadfont # All European languages
[ $plang != "el" ] && zcat /lib/consolefonts/LatArCyrHeb-8x16.psfu.gz | loadfont # no Greek
#translate rest of splitted script (= init2) to boot param plang #L18L
[ $plang -a -f /boot_msg/${plang} ] &&  mv /init2 /trans && sed -f /boot_msg/${plang} /trans > /init2 && rm /trans
. /init2
Start it from grub with plang=el (Greek)
It is not "all Greek :D "
or
plang=ru (Russian)
It is not "all Cyrillic :D "
or
plang=de (German)

edited:
bug, use next version 8 posts down please

Further on the script optimization

Posted: Fri 21 Oct 2011, 14:45
by Moose On The Loose
[quote="technosaurus"

Code: Select all

[ -e /etc/locale/${LANG:0:2}/init ] && . /etc/locale/${LANG:0:2}/init
[/quote]

Since you need the 1st two characters in more than one place, it may be worth doing that once at the top and making a variable of just the 1st two.

Now to the main subject of this:

On the case for doing the fonts, I think it would be best if the case statement only assigned variables and then the real action happen afterwards. This way, a check that it worked or didn't can be done and perhaps the user warned.

It also looked like nearly the same code is repeated many times. There should be some way to reduce this down.

Re: internationalization of initrd messages at bootup

Posted: Fri 21 Oct 2011, 15:02
by Moose On The Loose
L18L wrote: `echo $LANG | cut -d '_' -f 1` (or equivalent in pure shell)
would serve 3-letters coded languages too, they exist :)

Code: Select all

FIRST=${LANG/_*/}
If they then add a 4 letter language, it will work