internationalization of initrd messages at bootup

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: Further on the script optimization

#21 Post by L18L »

Moose On The Loose wrote: 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 appears to me you did not run i18n in console_i18n_demo so you doubt about it. I cannot see any reason why a simple loadfont should not work 8)
Moose On The Loose wrote: It also looked like nearly the same code is repeated many times. There should be some way to reduce this down.
Sorry, which code? Could you elaborate please?
Moose On The Loose wrote:

Code: Select all

FIRST=${LANG/_*/}
Very nice, thank you :)
User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

Re: Further on the script optimization

#22 Post by technosaurus »

L18L wrote:
Moose On The Loose wrote:

Code: Select all

FIRST=${LANG/_*/}
Very nice, thank you :)
${LANG%_*} is more portable (though not as portable as ${LANG:0:2}, Do any of these mystery locales not have unique first 2 chars?)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

Re: Further on the script optimization

#23 Post by technosaurus »

Moose On The Loose wrote: 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.
If you ever want to tell the user if something fails during boot, you can do a couple of things:
some_command 2>/dev/console
or
some_command 2>/dev/null || echo $ERRORMESSAGE >/dev/console

the first case uses command's error message (may not be localized)
the second outputs a localizable error message IFF the command fails
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
User avatar
Moose On The Loose
Posts: 965
Joined: Thu 24 Feb 2011, 14:54

Re: Further on the script optimization

#24 Post by Moose On The Loose »

L18L wrote: It appears to me you did not run i18n in console_i18n_demo so you doubt about it. I cannot see any reason why a simple loadfont should not work 8)
I didn't run it. However "should not work" is very like "I should be rich and good looking". Somehow the universe conspires to make things that "should be" happen to be "It aint"
Moose On The Loose wrote: It also looked like nearly the same code is repeated many times. There should be some way to reduce this down.
Sorry, which code? Could you elaborate please?
You have the same calls in each case. It is only the font that gets loaded that varies. It seems like there should be a way to make it so you use one call with the arguments changed magically.
User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

Re: Further on the script optimization

#25 Post by technosaurus »

Moose On The Loose wrote: You have the same calls in each case. It is only the font that gets loaded that varies. It seems like there should be a way to make it so you use one call with the arguments changed magically.
you could, but it would be dumb, because it is inside a case statement (only one is actually executed, but it is a little disconcerting to see until you get used to it)

if there were more than 10 it may be useful to set up a function, but the function itself requires code and has its own overhead ... perhaps when we get the Klingon, Vulcan and various Middle Earth translations, it will be worth it though

if you were to set a variable and then exec the command afterwards, the variable setting will be "duplicate" code ... sure if you choose a short/meaningless variable name you can save the difference in bytes between the actual text of the variable and command, but then it ends up allocating RAM (which in an initramfs comes from the same place)

when the initrd gets compressed, duplicates of text are practically eliminated size-wize, so worrying about a few extra imaginary bytes at the expense of readability is pointless
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

internationalization of initrd messages at bootup

#26 Post by L18L »

Thanks to the comments of MooseOnTheLoose and technosaurus (don't let us forget sc0tman's slovio :) ) here is now a version including a little menu.

The names of the languages are in 1st line of translation file.
Example for Russian:

Code: Select all

s#English#pу
Attachments
initrd_boot_menu.png
-
(2.65 KiB) Downloaded 1199 times
puppy_init_i18n_menu.tar.gz
to be merged into initrd
(37.7 KiB) Downloaded 494 times
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: internationalization of initrd messages at bootup

#27 Post by L18L »

L18L wrote:I am using it in wary5.2
I am using it in slacko52 now.

GUI to edit initrd.gz
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

multi-byte strings

#28 Post by L18L »

multi-byte char ↓ (arrow down) in initrd :D

s#Type a number to choose which personal file to use:# Tipp eine ...
Attachments
arrow_down_in_action.jpg
(13.61 KiB) Downloaded 875 times
amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#29 Post by amigo »

They should remain separate -I have a 'de' keyboard but use English and I imagine there are others that do similar.
User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#30 Post by technosaurus »

also you can use read -t <seconds>

but here is are a couple little chunks

Code: Select all

cd $DIR
i=0; for x in *; do i=$(($i+1)) && echo "( $i ) $x"; done

read -t 10 x
echo * |awk '{print $'${x:-$defaultvalue}'}'
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

multi-byte char ↓ (arrow down) in initrd

#31 Post by L18L »

amigo wrote:They should remain separate -I have a 'de' keyboard but use English and I imagine there are others that do similar.
Sorry, I have no idea what you wanted to tell me :roll:
In his blog BarryK wrote:However, 'echo' strings would probably have to stay as ascii only, as I have not yet configured Busybox as multi-byte aware (I did experiment with that awhile back but rolled back).
This was meant to be just a little demonstration of using a multi-byte char in busybox successfully :)
Last edited by L18L on Tue 13 Dec 2011, 18:07, edited 1 time in total.
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

little chunks

#32 Post by L18L »

technosaurus wrote:also you can use read -t <seconds>

but here is are a couple little chunks

Code: Select all

cd $DIR
i=0; for x in *; do i=$(($i+1)) && echo "( $i ) $x"; done

read -t 10 x
echo * |awk '{print $'${x:-$defaultvalue}'}'
I will be able to use them as replacements for ls and pause :)
Thank you.
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

internationalization of initrd messages at bootup

#33 Post by L18L »

# pwd
/initrd/mnt/dev_save/racy5225
# ls -l initrd.gz*
-rw-r--r-- 1 root root 3477530 2012-02-13 13:51 initrd.gz
-rw-r--r-- 1 root root 3475506 2012-02-09 12:00 initrd.gz.orig
#

What was added?

usr/share/locales/de/init (complete)
usr/share/locales/ru/init (just some automatically translated phrases)

# pwd
/initrd/mnt/dev_save/racy5225/puppy-init/usr/share/locales/ru
# cat init
#Pу
Attachments
addition_to_initrd.tar.gz
(33.02 KiB) Downloaded 610 times
Last edited by L18L on Tue 14 Feb 2012, 13:08, edited 1 time in total.
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

internationalization of initrd messages at bootup

#34 Post by L18L »

As there are some issues using the script t12s here is an altenative method for all who like to boot up in their own language (sorry: no Chinese, Japanese, Korean).
Arab and Hebrew use text editor yudit.
French: Deja fait par esmourguit

Just translate the following lines to your language.
1st line: your language in your language.
Let $.... unchanged
Post the translation here as file named
init.<your-language-code>
for inclusion in next initrd as
usr/share/locales/<your-language-code>/init

Thanks :)

#English
_M_10="${DROPOUT} not found. Dropping out to initial-ramdisk console..."
_M_1="0 none"
_M_11="Dropped to initramfs shell. Type 'exec switch' to continue booting Puppy."
_M_12="Dumping last lines of kernel log..."
_M_13="Dumping last lines of /tmp/bootinit.log..."
_M_14="ENTER key only to copy: "
_M_15="ENTER only to upgrade: "
_M_16="ERROR: Windows NTFS hibernated partition, cannot mount"
_M_17="failed"
_M_18="Folder $ONEFOLDER marked bad."
_M_19="from version $xOLDPVERSION"
_M_20="Hit the ENTER key only if it is okay to upgrade this file, or to not use it and boot up in RAM only type any other printable character."
_M_2="'${1}' filesystem check, please wait..."
_M_21="Increasing $PUPSAVEFILE by $KILOBIG Kbytes, please wait..."
_M_22="Loading drivers needed to access disk drives"
_M_23="Loading folder $ONEFOLDER from CD/DVD..."
_M_24="Loading personal file $PUPSAVEFILE ($PUPSAVEDEV)..."
_M_25="Loading '${PKEYS}' keyboard layout..."
_M_26="Loading the '${basepupsfs}' main file..."
_M_27="Mounting encrypted $PUPSAVEFILE..."
_M_28="NOTICE: As you type your password nothing will be displayed on the screen for absolute security. Just type it in then press ENTER key..."
_M_29="Overlaying preconfig files..."
_M_30="Overwritten old files have been moved to /tmp/versioncleanup/"
_M_31="Password: "
_M_32="pausing"
_M_33="Pausing for 60 seconds..."
_M_34="Performing a 'switch_root' to the layered filesystem..."
_M_35="RAM full"
_M_36="'save file' filesystem check, please wait..."
_M_37="Searching for Puppy files..."
_M_38="Setting up the layered filesystem..."
_M_39="SORRY, cannot check filesystem"
_M_3="After bootup please examine this directory (before shutdown) for anything that you might like to recover. Pausing 30 secs so you can read this msg..."
_M_40="SORRY, cannot resize $PUPSAVEFILE"
_M_41="...successfully mounted"
_M_42="The main Puppy file '${basepupsfs}' is being loaded off the optical disc."
_M_43="then on next boot it will load fast. Type any printable char not to copy it."
_M_44="This is a radical file cleanup for broken systems, could alter some settings."
_M_45="This is a simulated version upgrade, which performs a file cleanup."
_M_46="This save-file was last used with version $OLDDISTRO_VERSION of Puppy"
_M_47="Type a number to choose which personal file to use:"
_M_48="Version update, restoring 'official' files, please wait..."
_M_49="Very slow! Type ENTER key only to copy it to the same partition as the save-file"
_M_4="Backing off, not using save-file, booting in RAM only, PUPMODE=5..."
_M_50="(with a slow CPU this may take sometime, please be patient)"
_M_51="You are upgrading Puppy ${OLDstr} to ${NEWPVERSION}."
_M_5="'${basepupsfs}' now copying to hard drive (but only available next boot)..."
_M_6="Can't mount file, press ENTER key to try again, or any other char then ENTER for f.s. check then try again, or for developers type 'quit' to drop out to console: "
_M_7="...continuing with loading $PUPSAVEFILE..."
_M_8="copying to ram"
_M_9="done"
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

internationalization of initrd messages at bootup

#35 Post by L18L »

Menu is populated now by

Arabic (just some automatically translated phrases)
and French (complete translation by toutou´s creator esmourguit)

Font LatArCyrHeb-16.psfu.gz is added which enables Arabic and Hebrew.
Attachments
addition2_to_initrd.tar.gz
(39.18 KiB) Downloaded 620 times
rodin.s
Posts: 344
Joined: Wed 22 Sep 2010, 19:50
Location: Ukraine

Russian translation

#36 Post by rodin.s »

I have made Russian translation. But it works only for three top lines. Some other file (/etc/rc.d/rc.sysinit) has to be translated for the rest.
But it's good that Russian font in console is loaded in initrd and all Russian messages in console displayed well. My unicode pet is not needed.

Edit: gettext doesn't work in /etc/rc.d/rc.sysinit.
Edit2: No. I was wrong. Gettext works in /etc/rc.d/rc.sysinit. And now all console boot messages are in Russian.
Attachments
init.gz
Russian translation
(3.33 KiB) Downloaded 592 times
rc_sysinit.tar.gz
i18n with gettext of /etc/rc.d/rc.sysinit, pot file and ru.po and mo.
(12.75 KiB) Downloaded 611 times
Last edited by rodin.s on Wed 15 Feb 2012, 11:09, edited 1 time in total.
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: Russian translation

#37 Post by L18L »

rodin.s wrote:I have made Russian translation. But it works only for three top lines. Some other file (/etc/rc.d/rc.sysinit) has to be translated for the rest.
But it's good that Russian font in console is loaded in initrd and all Russian messages in console displayed well. My unicode pet is not needed.

Edit: gettext doesn't work in /etc/rc.d/rc.sysinit.
Thank you very much rodin.s,

Your way of distributing the translation file is very good. I like it,
English as comment and an empty line

Code: Select all

#Ру
rodin.s
Posts: 344
Joined: Wed 22 Sep 2010, 19:50
Location: Ukraine

Russian translation

#38 Post by rodin.s »

I have found one small mistake in my translation (variable _M_8 was _M_7). init.gz is re-uploaded.
There is one strange but positive thing. When I boot pfix=ram and choose ru in initrd I got quicksetup in Russian while locale is set to en.
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: Russian translation

#39 Post by L18L »

rodin.s wrote:I have found one small mistake in my translation (variable _M_8 was _M_7). init.gz is re-uploaded.
Thanks, I have updated my copy. Will be in next upload.
rodin.s wrote:There is one strange but positive thing. When I boot pfix=ram and choose ru in initrd I got quicksetup in Russian while locale is set to en.
The strange thing was intended 8)
It is done by setting LANGUAGE

At the moment this is not set properly as I did not know another way: It was written into /pup_rw/etc/rc.d/PUPSTATE by init script and can be found in puppy in the file /etc/rd.d/PUPSTATE.

Bad consequence is: You cannot run a program in another language

Code: Select all

LANGUAGE=de quicksetup
will stay in Russian for you
because quicksetup (and almost every other program is reading PUPSTATE and thus always stay Russian)

This is not good. I think people like me like to switch to another LANGUAGE sometimes.

fix:

Code: Select all

# [ `grep -E '^LANGUAGE=' /etc/rc.d/PUPSTATE` ] && ( mv /etc/rc.d/PUPSTATE P; sed 's/^LANGUAGE=/\#LANGUAGE=/' P > /etc/rc.d/PUPSTATE; rm P )
This one-liner makes the LANGUAGE=.. command in PUPSTATE to be a comment so you can use a LANGUAGE other than the one you have been booting.
This one-liner should be inserted maybe in quicksetup?

Or is there another better way for booting language being passthrough´ed :?:
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

gettext at bootup

#40 Post by L18L »

rodin.s wrote:...
Edit: gettext doesn't work in /etc/rc.d/rc.sysinit.
Edit2: No. I was wrong. Gettext works in /etc/rc.d/rc.sysinit. ...
It did not work with me.

And now I remember why I did not not publish the before mentioned script from 2010: it did not work.

And now it is clear why not:
quote from http://www.gnu.org/software/gettext/man ... iable.html
Note: The variable LANGUAGE is ignored if the locale is set to ‘C’. In other words, you have to first enable localization, by setting LANG (or LC_ALL) to a value other than ‘C’, before you can use a language priority list through the LANGUAGE variable.


At the time of running /etc/rc.d/rc.sysinit there is no locale set. That´s it!

When the desktop has been started there is a locale: LANG=en_US
and gettext prefers the LANGUAGE which was set as boot parameter or chosen in the menu.

I have made a version of rc.sysinit using t12s
tested succesfully in Russian and German.

The translation file was created from ru.po

Have fun :)
Attachments
rc.sysinit-t12s.tar.gz
/etc/rc.d/rc.sysinit
ru and de
(12.6 KiB) Downloaded 589 times
Post Reply