| Author |
Message |
L18L
Joined: 19 Jun 2010 Posts: 1717 Location: Burghaslach, Germany
|
Posted: Fri 21 Oct 2011, 06:17 Post subject:
internationalization of initrd messages at bootup Subject description: ${LANG:0:2} |
|
| 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: |
[ -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
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1717 Location: Burghaslach, Germany
|
Posted: Fri 21 Oct 2011, 06:55 Post subject:
internationalization of initrd messages at bootup Subject description: pkeys and/or plang |
|
| 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...
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1717 Location: Burghaslach, Germany
|
Posted: Fri 21 Oct 2011, 08:45 Post subject:
internationalization of initrd messages at bootup Subject description: proof of concept |
|
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: | [ $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 "
or
plang=ru (Russian)
It is not "all Cyrillic "
or
plang=de (German)
edited:
bug, use next version 8 posts down please
| Description |
only for people who know how to edit their initrd.gz
|

Download |
| Filename |
puppy_init_i18n.tar.gz |
| Filesize |
36.96 KB |
| Downloaded |
170 Time(s) |
Last edited by L18L on Mon 24 Oct 2011, 12:32; edited 1 time in total
|
|
Back to top
|
|
 |
Moose On The Loose

Joined: 24 Feb 2011 Posts: 279
|
Posted: Fri 21 Oct 2011, 10:45 Post subject:
Further on the script optimization Subject description: We can make the action happen after the case |
|
[quote="technosaurus"
| Code: |
[ -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.
|
|
Back to top
|
|
 |
Moose On The Loose

Joined: 24 Feb 2011 Posts: 279
|
Posted: Fri 21 Oct 2011, 11:02 Post subject:
Re: internationalization of initrd messages at bootup Subject description: ${LANG:0:2} |
|
| L18L wrote: |
`echo $LANG | cut -d '_' -f 1` (or equivalent in pure shell)
would serve 3-letters coded languages too, they exist  |
If they then add a 4 letter language, it will work
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1717 Location: Burghaslach, Germany
|
Posted: Fri 21 Oct 2011, 13:42 Post subject:
Re: Further on the script optimization Subject description: We can make the action happen after the case |
|
| 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
| 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: | |
Very nice, thank you
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Fri 21 Oct 2011, 22:10 Post subject:
Re: Further on the script optimization Subject description: We can make the action happen after the case |
|
| L18L wrote: |
| Moose On The Loose wrote: | |
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?)
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Fri 21 Oct 2011, 22:21 Post subject:
Re: Further on the script optimization Subject description: We can make the action happen after the case |
|
| 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
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
Moose On The Loose

Joined: 24 Feb 2011 Posts: 279
|
Posted: Fri 21 Oct 2011, 22:28 Post subject:
Re: Further on the script optimization Subject description: We can make the action happen after the case |
|
| 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
|
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"
| Quote: |
| 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.
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Fri 21 Oct 2011, 22:57 Post subject:
Re: Further on the script optimization Subject description: We can make the action happen after the case |
|
| 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
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1717 Location: Burghaslach, Germany
|
Posted: Sun 23 Oct 2011, 14:23 Post subject:
internationalization of initrd messages at bootup Subject description: bugfix |
|
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:
the translation files for languages other than German are containing just some phrases for demonstration purposes only
1 problem remaining: consolefont for Arab and Hebrew
In my example script i18n both fonts were set by setfont
setfont is not available init initrd
So I have been using loadfont
But loadfont does NOT load LatArCyrHeb-16.psfu.gz
To enable Arabic and Hebrew languages busybox version in initrd must support setfont. Help me if you can... I cann't
Here the new init script
| Code: | #!/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
..
comments cut off
...
#/bin/hotplug2stdout_notimeout > /tmp/pup_event_uevents_initrd &
# i18n
zcat /lib/consolefonts/LatGrkCyr-8x16.psfu.gz | loadfont # All European languages; new default ?!
# I assume setfont instead of loadfont would work but it is not supported in this busybox of initrd
#case $plang in
## ar|iw) zcat /lib/consolefonts/LatArCyrHeb-16.psfu.gz | loadfont ;; # no Greek # not working
# ar|iw) setfont /lib/consolefonts/LatArCyrHeb-16.psfu.gz -C /dev/tty1 ;; # no Greek # setfont needed?
#esac
if [ "$plang" = "" ]; then # plang could be set in menu.lst or elsewhere...
# a litte menu to choose language from translation files
cd boot_msg
x=-1; nmax=`ls | wc -w`
while [ $x -lt 0 -o $x -gt $nmax 2>/dev/null ]; do
clear; echo "
"
n=0; echo " ${n} <--- "English
for lang in `ls`; do
n=`expr $n + 1`
read LINE <$lang
LINE=`echo $LINE | cut -d '#' -f 3`
echo " ${n} <--- "$LINE
done
echo -n "
? "
read x
x=`echo $x | sed -e s/[^0-9]//g`
done
# now find the directory...it is the x-th word of ls
dir=`ls`
plang=`echo $dir | cut -d ' ' -f $x 2>/dev/null`
cd - >/dev/null
# end of menu
fi
#translate rest of splitted script (= init2) to boot param plang or chosen in above menu
[ $plang -a -f /boot_msg/${plang} ] && mv /init2 /trans && sed -f /boot_msg/${plang} /trans > /init2 && rm /trans
. /init2
# end of i18n |
The screenshot is simulated in X.
It works in real boot process with another font of course.
I am using it in wary5.2
| Description |
- |
| Filesize |
2.65 KB |
| Viewed |
724 Time(s) |

|
| Description |
to be merged into initrd
|

Download |
| Filename |
puppy_init_i18n_menu.tar.gz |
| Filesize |
37.7 KB |
| Downloaded |
180 Time(s) |
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1717 Location: Burghaslach, Germany
|
Posted: Wed 26 Oct 2011, 09:15 Post subject:
Re: internationalization of initrd messages at bootup Subject description: GUI to edit initrd.gz |
|
| L18L wrote: | | I am using it in wary5.2 |
I am using it in slacko52 now.
GUI to edit initrd.gz
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1717 Location: Burghaslach, Germany
|
Posted: Tue 13 Dec 2011, 09:55 Post subject:
multi-byte strings Subject description: arrow-down |
|
multi-byte char ↓ (arrow down) in initrd
s#Type a number to choose which personal file to use:# ↓ Tipp eine ...
| Description |
|
| Filesize |
13.61 KB |
| Viewed |
507 Time(s) |

|
|
|
Back to top
|
|
 |
amigo
Joined: 02 Apr 2007 Posts: 1759
|
Posted: Tue 13 Dec 2011, 12:27 Post subject:
|
|
They should remain separate -I have a 'de' keyboard but use English and I imagine there are others that do similar.
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Tue 13 Dec 2011, 12:46 Post subject:
|
|
also you can use read -t <seconds>
but here is are a couple little chunks
| Code: | cd $DIR
i=0; for x in *; do i=$(($i+1)) && echo "( $i ) $x"; done
read -t 10 x
echo * |awk '{print $'${x:-$defaultvalue}'}' |
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
|