Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 22 Sep 2014, 00:22
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
internationalization of initrd messages at bootup
Moderators: Flash, Ian, JohnMurga
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 2 of 4 Posts_count   Goto page: Previous 1, 2, 3, 4 Next
Author Message
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Sun 23 Oct 2011, 14:23    Post_subject: internationalization of initrd messages at bootup
Sub_title: bugfix
 

Thanks to the comments of MooseOnTheLoose and technosaurus (don't let us forget sc0tman's slovio Smile ) 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:
s#English#pусский#


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
initrd_boot_menu.png
 Description   -
 Filesize   2.65 KB
 Viewed   1013 Time(s)

initrd_boot_menu.png

puppy_init_i18n_menu.tar.gz
Description  to be merged into initrd
gz

 Download 
Filename  puppy_init_i18n_menu.tar.gz 
Filesize  37.7 KB 
Downloaded  272 Time(s) 
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Wed 26 Oct 2011, 09:15    Post_subject: Re: internationalization of initrd messages at bootup
Sub_title: 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
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Tue 13 Dec 2011, 09:55    Post_subject: multi-byte strings
Sub_title: arrow-down
 

multi-byte char ↓ (arrow down) in initrd Very Happy

s#Type a number to choose which personal file to use:# Tipp eine ...
arrow_down_in_action.jpg
 Description   
 Filesize   13.61 KB
 Viewed   687 Time(s)

arrow_down_in_action.jpg

Back to top
View user's profile Send_private_message 
amigo

Joined: 02 Apr 2007
Posts: 2247

PostPosted: 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
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4351

PostPosted: 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}'}'

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Tue 13 Dec 2011, 13:54    Post_subject: multi-byte char ↓ (arrow down) in initrd  

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 Rolling Eyes

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 Smile

Edited_time_total
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Tue 13 Dec 2011, 14:06    Post_subject: little chunks  

technosaurus wrote:
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}'}'


I will be able to use them as replacements for ls and pause Smile
Thank you.
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Mon 13 Feb 2012, 14:04    Post_subject: internationalization of initrd messages at bootup
Sub_title: using t12s now
 

# 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усский
_M_17="смогли"
_M_2="'${1}' проверки файловой системы, пожалуйста, подождите ..."
_M_22="Загрузка драйвера, необходимые для доступа к дискам"
_M_25="Загрузка '${PKEYS}' раскладку клавиатуры..."
_M_36="Загрузка драйвера, необходимые для доступа к дискам"
_M_37="Поиск Puppy файлы..."
_M_9="сделал"
#

Important: 1st line has to have name of language as a comment (ex: #Pусский), this is used in a menu.

What else was added?

LatGrkCyr-8x16.psfu.gz a font for LatinGreekCyrillic

Changes in script init:

- New boot parameter plang for language (ex: de or ru)

- If plang is not set then there is a menu for choosing from included languages.

- OUTPUT_CHARSET=UTF-8 is passed through to puppy.
This enables correct output also if utf8 is NOT activated.
Tested successfully with pizzasgood´s retrovol (C code)
and puppy will immediately start in the chosen language

_____________
edited
Other languages

Extract attachment and start
Code:
t12s init

Translation file init will be in /usr/share/locales/<language>


__________________________
edited
update see 2 posts down please
addition_to_initrd.tar.gz
Description 
gz

 Download 
Filename  addition_to_initrd.tar.gz 
Filesize  33.02 KB 
Downloaded  282 Time(s) 

Edited_time_total
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Tue 14 Feb 2012, 07:54    Post_subject: internationalization of initrd messages at bootup
Sub_title: other Languages
 

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 Smile

#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"
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Tue 14 Feb 2012, 09:07    Post_subject: internationalization of initrd messages at bootup
Sub_title: update
 

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.
addition2_to_initrd.tar.gz
Description 
gz

 Download 
Filename  addition2_to_initrd.tar.gz 
Filesize  39.18 KB 
Downloaded  283 Time(s) 
Back to top
View user's profile Send_private_message 
rodin.s

Joined: 22 Sep 2010
Posts: 338
Location: Ukraine

PostPosted: Tue 14 Feb 2012, 15:05    Post_subject: Russian translation  

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.
init.gz
Description  Russian translation
gz

 Download 
Filename  init.gz 
Filesize  3.33 KB 
Downloaded  293 Time(s) 
rc_sysinit.tar.gz
Description  i18n with gettext of /etc/rc.d/rc.sysinit, pot file and ru.po and mo.
gz

 Download 
Filename  rc_sysinit.tar.gz 
Filesize  12.75 KB 
Downloaded  303 Time(s) 

Edited_time_total
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Tue 14 Feb 2012, 16:35    Post_subject: Re: Russian translation  

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:
#Русский
#_M_10="${DROPOUT} not found. Dropping out to initial-ramdisk console..."
_M_10="${DROPOUT} не найден. Будет запущена консоль инит-рамдиска..."

#_M_1="0 none"
_M_1="0 нет"


Yes it are usually just the first (3 ?) lines from initrd.

I have found a folder puppy_rcd_i18n made by me
dated from July 2010
containing all scripts of rc.d gettexted
was never published
but if I remember correctly it was running in puppy4.3.1 Cool

Stuff for the next days....

-----
edited
Now I have seen your change: gettext is working Very Happy Very Happy
Back to top
View user's profile Send_private_message 
rodin.s

Joined: 22 Sep 2010
Posts: 338
Location: Ukraine

PostPosted: Wed 15 Feb 2012, 07:16    Post_subject: Russian translation  

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.
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Wed 15 Feb 2012, 09:22    Post_subject: Re: Russian translation
Sub_title: positive thing
 

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 Cool
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:
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:
# [ `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 Question
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Wed 15 Feb 2012, 16:35    Post_subject: gettext at bootup
Sub_title: work or not work :?:
 

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/manual/html_node/The-LANGUAGE-variable.html
Quote:
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 Smile
rc.sysinit-t12s.tar.gz
Description  /etc/rc.d/rc.sysinit
ru and de
gz

 Download 
Filename  rc.sysinit-t12s.tar.gz 
Filesize  12.6 KB 
Downloaded  272 Time(s) 
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 2 of 4 Posts_count   Goto page: Previous 1, 2, 3, 4 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1185s ][ Queries: 12 (0.0060s) ][ GZIP on ]