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/

internationalization of initrd messages at bootup

#16 Post 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 :)

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

internationalization of initrd messages at bootup

#17 Post 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...

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

internationalization of initrd messages at bootup

#18 Post 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
Attachments
puppy_init_i18n.tar.gz
only for people who know how to edit their initrd.gz
(36.96 KiB) Downloaded 498 times
Last edited by L18L on Mon 24 Oct 2011, 16:32, edited 1 time in total.

User avatar
Moose On The Loose
Posts: 965
Joined: Thu 24 Feb 2011, 14:54

Further on the script optimization

#19 Post 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.

User avatar
Moose On The Loose
Posts: 965
Joined: Thu 24 Feb 2011, 14:54

Re: internationalization of initrd messages at bootup

#20 Post 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

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 489 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 603 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 609 times

Post Reply