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 Fri 24 Oct 2014, 19:56
All times are UTC - 4
 Forum index » Advanced Topics » Puppy Projects » Localization Project
QuickLocaleSwitcher for people who have more than 1 langpack
Moderators: Lobster, MU, raffy
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 2 Posts_count   Goto page: 1, 2 Next
Author Message
L18L

Joined: 19 Jun 2010
Posts: 2530
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Sun 14 Apr 2013, 14:58    Post_subject:  QuickLocaleSwitcher for people who have more than 1 langpack
Sub_title: HOWTO make your langpack to NOT overwrite other languages
 

If you have more than just English then his is for you.

If you have exactly one locale (and its langpack) other than English then this is for you.

If you have several locales (and their langpacks) other than English then this is for you.

_________________________________________________
EDIT

There is something better now

no yad needed
new button in jwm tray

http://www.murga-linux.com/puppy/viewtopic.php?p=769153
_________________________________________________



What is different from original Puppy?
When you change locale in Puppy then you must restart X: and all apps are away.
This new switcher is just restarting JWM and rox.
All utils and apps launched from desktop icon or from menu run in the new locale.

QuickLocaleSwitcher is in /usr/bin and desktop menu.

Translatable by momanger. -NLS.pet would follow if some translations were posted here. Wink

[edit] Note,
GUI improved:
2 and more foreign languages: there are choices
1 foreign language: toggles languages without interaction
0 foreign language: see screenshot
[/edit]

Have fun Very Happy

[edit]The emphasize ist not at "Quick" but at "change without restart of X"[/edit]

[edit]Version 0.4 improved
check for dependencies
some bugs fixed
[/edit]
quicklocaleswitch-0.4.pet
Description 
pet

 Download 
Filename  quicklocaleswitch-0.4.pet 
Filesize  4 KB 
Downloaded  192 Time(s) 
quicklocaleswitch-0.3.pet
Description 
pet

 Download 
Filename  quicklocaleswitch-0.3.pet 
Filesize  3.85 KB 
Downloaded  319 Time(s) 
QuickLocaleSwitch_0.3_en.png
 Description   
 Filesize   22.49 KB
 Viewed   452 Time(s)

QuickLocaleSwitch_0.3_en.png

quicklocaleswitch-0.2.pet
Description 
pet

 Download 
Filename  quicklocaleswitch-0.2.pet 
Filesize  3.72 KB 
Downloaded  311 Time(s) 
QuickLocaleSwitch_0.2_ru.png
 Description   quick switch between Russian and German
 Filesize   59.16 KB
 Viewed   457 Time(s)

QuickLocaleSwitch_0.2_ru.png

quicklocaleswitch-0.1.pet
Description 
pet

 Download 
Filename  quicklocaleswitch-0.1.pet 
Filesize  3.49 KB 
Downloaded  375 Time(s) 
quickLocaleSwitch.png
 Description   
 Filesize   35.82 KB
 Viewed   629 Time(s)

quickLocaleSwitch.png


Edited_times_total
Back to top
View user's profile Send_private_message 
Bert


Joined: 30 Jun 2006
Posts: 950

PostPosted: Sun 14 Apr 2013, 15:29    Post_subject:  

This looks like a brilliant piece of work again, L18L!

I don't pretend to completely understand how it does what it does, but I've never seen anything lke it before...congrats!

Anyway, while I'm drinking a very good coffee and enjoying my first kernel panic ever -while translating with momanager-, I can only feel grateful for guys like you...

Is it correct to say this is "on-the-fly 're-localisation'", without losing the active apps?Or do you mean all apps traditionally default in Puppy are instantly available in the new language?

My innocent first impression is, this could be a great tool for translators too. I will ask The Little Grey Cells why this would be so Wink

Thanks for this exciting development!.

_________________


Back to top
View user's profile Send_private_message 
vicmz


Joined: 15 Jan 2012
Posts: 1117

PostPosted: Sun 14 Apr 2013, 19:32    Post_subject:  

Cool Cool
I'd like to learn German, Japanese, Chinese, and Korean.

_________________
OB Precise 14.07.26 Woof-CE|Puppy Linux en español
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2530
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Mon 15 Apr 2013, 04:17    Post_subject: learning German
Sub_title: babbel.com
 

vicmz wrote:
Cool Cool
I'd like to learn German, ...


Nivel principiante Question
http://lp.babbel.com/d/SPA_tutorial.html?l1=SPA&l2=DEU&autostart=beginner&ch=ORG Idea

[edit] returning now from 1st lesson of learning Dutch for Espanols Laughing
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2530
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Mon 15 Apr 2013, 05:30    Post_subject: QuickLocaleSwitcher
Sub_title: what and how
 

Thanks for the nice words, Bert.
Bert wrote:
I don't pretend to completely understand how it does what it does, but I've never seen anything lke it before...congrats!
How it does what it does
In Puppy you seem to have chosen activation of locale nl_NL
default is en_US, English is always there because English messages are used by the coders.
If you have no other locale there would be no GUI, the locale would just toggle to en_US or back to nl_NL.
But I hope that you have installed German langpack_de and chosen locale de_** once.
Then i.e. if you have more than 2 locales you have the GUI showed in 1st post.
It uses default fixmenus (a bit tuned for speed) and default fixdesk.
If you start it from command line (copy Code to a console anpress ENTER)
Code:
QuickLocaleSwitch
then you will see how many ( Question ) seconds it needs for what it does. Chosen new locale is updated in file /etc/profile.

Bert wrote:
Is it correct to say this is "on-the-fly 're-localisation'", without losing the active apps?
Or do you mean all apps traditionally default in Puppy are instantly available in the new language?

It is "on-the-fly 're-localisation'", without losing the active apps
but only for the dault apps which are listed if you run:
Code:
ls /usr/local/bin/default*

I have changed their code for example for defaultcalendar from
Code:
#!/bin/sh
osmo $@

to
Code:
#!/bin/sh
eval `grep '^LANG=' /etc/profile`
osmo $@

that is inserted 1 line wich is taking locale from (actualized) /etc/profile
Now you should be able to
start "plan" from desktop icon
switch locale
start "plan" from desktop icon in the new language
If you cannot then please report. version is just 0.1 Wink

Other apps stay with the old locale because they all are running under xwin. And restarting xwin would kill all apps.

But if you start from console (which is a defaultapp) then it is in new locale. Wink
osmo_nl_de.png
 Description   Exemple for
One app in 2 different locales active
 Filesize   8.99 KB
 Viewed   588 Time(s)

osmo_nl_de.png

Back to top
View user's profile Send_private_message 
vicmz


Joined: 15 Jan 2012
Posts: 1117

PostPosted: Tue 16 Apr 2013, 17:32    Post_subject:  

Another Chinese lessons link with lots of downloads, recommended if you seriously plan to learn:

http://ocw.mit.edu/resources/res-21f-003-learning-chinese-a-foundation-course-in-mandarin-spring-2011/online-textbook/part-i-introduction-units-1-4-character-lessons-1-3/

_________________
OB Precise 14.07.26 Woof-CE|Puppy Linux en español
Back to top
View user's profile Send_private_message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Thu 18 Apr 2013, 14:29    Post_subject:  

fixmenus looks good !

Will test it later cos i have LANG out of /etc/profile cos I am still experimenting on not to call /etc/profile from .bashrc all of the time .

Heres another snapshot of a chooselocale experiment of mine :
chooselocale-table.jpg
 Description   
 Filesize   55.94 KB
 Viewed   536 Time(s)

chooselocale-table.jpg

Back to top
View user's profile Send_private_message Visit_website 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Thu 18 Apr 2013, 18:09    Post_subject:  

First test in my messed up frugal Macpup529 works. Have en_US and de_DE (.URGS-EIGHT) and it switches kinda fine ( jwm ) .
I need some time to detect thingys .
Am missing the gui to choose another locale as the pic shows in your first post .

Cheers !
Back to top
View user's profile Send_private_message Visit_website 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Thu 18 Apr 2013, 19:08    Post_subject:  

Got it, when only two languages then comes no gui . gui missing ut8 or not utf8 mentioning .
QLS.jpg
 Description   
 Filesize   21.13 KB
 Viewed   515 Time(s)

QLS.jpg

Back to top
View user's profile Send_private_message Visit_website 
L18L

Joined: 19 Jun 2010
Posts: 2530
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Fri 19 Apr 2013, 12:46    Post_subject: QuickLocaleSwitcher
Sub_title: utf8
 

Karl Godt wrote:
... gui missing ut8 or not utf8 mentioning .

That was intented to not confuse noobees.
Look into the script: there is a tail -n1 which would guarantee a result of utf8
What I really want is: just change language. (QuickLanguageSwitcher)

Example: Danish in north Schleswig-Holstein (that they exist we do know since last votes)
What is their locale?
da_DE or da_DK

They would have usage of switch from da to de and back....
But it is really just the language (LC_MESSAGES for GNU software)

fixdesk is without changes now. Quick enough.
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2530
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Fri 19 Apr 2013, 13:55    Post_subject:  

Karl Godt wrote:
...Heres another snapshot of a chooselocale experiment of mine :

I find these long lists very annoying (and difficult to select th right one sometimes)
Easier for the user would be 1- choose language
then 1 country out of some countries.

Very interesting that you are experimenting too!
Back to top
View user's profile Send_private_message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Fri 19 Apr 2013, 15:37    Post_subject:  

That code is much faster than the original chooselocale formatting loop and contains more info . Not a Nooby and dont want offered a head -n1 -> iso-8859-1 if i want iso-8859-2 if i would be a Tchechoslowakian .
Code:

#!/bin/sh
# Karl Reimer Godt April 2013

Version=1.00
start_dir="$PWD"
tmpDir=/tmp/locale
mkdir -p $tmpDir/log
[ "$start_dir" ] || start_dir=$tmpDir

for i in $(ls -1 /usr/share/i18n/locales) ; do
AVAIL_LANGS="$AVAIL_LANGS
${i}| `grep -m1 '^title' /usr/share/i18n/locales/$i |sed 's%^title[[:blank:]]*%%'`"
done

echo "$AVAIL_LANGS" | grep -viE 'posix|translit|i18n|iso|^$' >/tmp/AVAIL_LANGS.lst

export ChooseLocaleMainWindow="
<window title=\"chooselocale\">
<vbox>
 <hbox>
  <text><label>Select the language</label></text>
 </hbox>
 <hbox>
  <frame Language>
   <table>
   <label>Available Languages in i18n locales | Description</label>
   <variable>MY_LANG</variable>
   <input>cat /tmp/AVAIL_LANGS.lst</input>
   <action>echo \$MY_LANG >/tmp/LANG_sel</action>
   <width>700</width><height>180</height>
   </table>
  </frame>
 </hbox>

<hbox>
<text><label>Select the char map</label></text>
</hbox>

<hbox>
<frame Charmap>
   <table>
   <label>Available Character Maps in i18n charmaps</label>
   <variable>MY_MAP</variable>
   <input>ls -1 /usr/share/i18n/charmaps</input>
   <action>echo $MY_MAP >/tmp/MAP_sel</action>
   <width>700</width><height>180</height>
   </table>
</frame>
</hbox>
<hbox>
 <button ok></button>
 <button cancel></button>
</hbox>
</vbox>
</window>
"

eval `gtkdialog --program=ChooseLocaleMainWindow`
#: MY_LANG="de_DE"
#: MY_MAP="IBM1132.gz"
#: EXIT="OK"

[ "$EXIT" = OK ] || exit 0
   [ "$MY_MAP" ] || exit 0
  [ "$MY_LANG" ] || exit 0

MAP=`echo "$MY_MAP" | sed 's%\..*$%%'`
echo "MAP=$MAP'"
echo "MY_LANG=$MY_LANG'"

localedef --no-archive -f $MAP -i $MY_LANG "${MY_LANG}.${MAP}" > $tmpDir/log/${MAP}.${MY_LANG}.log 2>&1
           RV=$?
echo "Return Value of localedef is < $RV >"

if [ "$RV" != 0 ] ; then
echo "$MY_LANG $MAP" >> /usr/share/i18n/UNSUPPORTED
ERROR_MSG=`tail -n 10 $tmpDir/log/"${MAP}.${MY_LANG}.log"`
xmessage -bg red "Failed to create correct Language

$ERROR_MSG"

cd /usr/lib/locale/
rmdir ${MY_LANG}*
cd "$start_dir"
exec $0

fi

grep "$MY_LANG" /usr/share/i18n/SUPPORTED | grep "$MAP" || echo "$MY_LANG $MAP" >> /usr/share/i18n/SUPPORTED

sed -i "s%^LANG=.*%LANG=${MY_LANG}\.${MAP}%" /etc/profile
[ $? = 0 ] || { xmessage -gb red "Sorry, probably /etc/profile corrupt."; exit 1; }

Xdialog --left --wrap --title "Glibc Locale setup" --ok-label "Restart X now" --cancel-label "Finished"  --yesno "Ok, the change has been made and will take effect at next boot. However, if you click the 'Restart X now' button X will exit then restart and the new locale will immediately take effect -- however make sure that all other applications are closed first as restarting X will rudely kill them! Otherwise, just click 'Finished' for the new locale to take effect at next boot.\n\nTechnical details:\nLocale files have been generated in /usr/lib/locale (if not already) and LANG variable set to ${MY_LANG}.${MAP} in /etc/profile." 0 100
 if [ $? -eq 0 ];then
  rm -rf /tmp/.X0-lock
  sync
  exec restartwm $CURRENTWM
 fi
Back to top
View user's profile Send_private_message Visit_website 
L18L

Joined: 19 Jun 2010
Posts: 2530
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Sat 20 Apr 2013, 07:36    Post_subject: chooselocale
Sub_title: Version 1.01
 

Karl Godt wrote:
.. Not a Nooby and dont want offered a head -n1 -> iso-8859-1 if i want iso-8859-2 if i would be a Tchechoslowakian .

All right
..and i think utf8 is enogh for the rest of the century
Here is my contribution (playing version with endless loop):
Code:
#!/bin/sh
# Karl Reimer Godt April 2013
# L18L without @euro and just UTF-8 and locales for 1 language

Version=1.01
start_dir="$PWD"
tmpDir=/tmp/locale
mkdir -p $tmpDir/log
[ "$start_dir" ] || start_dir=$tmpDir

for i in $(ls -1 /usr/share/i18n/locales) ; do
AVAIL_LANGS="$AVAIL_LANGS
${i}| `grep -m1 '^title' /usr/share/i18n/locales/$i |sed 's%^title[[:blank:]]*%%'`"
done
echo "$AVAIL_LANGS" | grep -viE 'posix|translit|i18n|iso|eur|^$' >/tmp/AVAIL_LANGS.lst

[ -f /tmp/AVAIL_LANGUAGES.lst ] || cat /tmp/AVAIL_LANGS.lst | cut -d' ' -f2| cut -d'"' -f2 | sort -u >/tmp/AVAIL_LANGUAGES.lst

while true; do # endless loop

MY_LANGUAGE=`cat /tmp/LANGUAGE_sel 2>/dev/null` || MY_LANGUAGE=`grep -m1 '^language' /usr/share/i18n/locales/${LANG%.*} | cut -d'"' -f2`


export ChooseLocaleMainWindow="
<window title=\"chooselocale $Version\">
<vbox>

 <hbox>
  <text><label>Select the language</label></text>
 </hbox>
 <hbox>
  <frame Language>
   <table>
   <label>Available Languages in i18n locales Description</label>
   <variable>MY_LANGUAGE</variable>
   <input>echo $MY_LANGUAGE; cat /tmp/AVAIL_LANGUAGES.lst</input>
   <action>echo \$MY_LANGUAGE >/tmp/LANGUAGE_sel</action>
   <width>700</width><height>135</height>
   </table>
  </frame>
 </hbox>

 <hbox>
  <text><label>Select the locale</label></text>
 </hbox>
 <hbox>
  <frame Locale>
   <table>
   <label>Available for $MY_LANGUAGE | Description</label>
   <variable>MY_LANG</variable>
   <input>cat /tmp/AVAIL_LANGS.lst | grep $MY_LANGUAGE</input>
   <action>echo \$MY_LANG >/tmp/LANG_sel</action>
   <width>700</width><height>220</height>
   </table>
  </frame>
 </hbox>

<hbox>
<text><label>Select the char map</label></text>
</hbox>

<hbox>
<frame Charmap>
   <table>
   <label>Should not One and only Character Map be enough for this World?</label>
   <variable>MY_MAP</variable>
   <input>echo UTF-8.gz</input>
   <action>echo $MY_MAP >/tmp/MAP_sel</action>
   <width>700</width><height>60</height>
   </table>
</frame>
</hbox>
<hbox>
 <button ok></button>
 <button cancel></button>
</hbox>
</vbox>
</window>
"

eval `gtkdialog --program=ChooseLocaleMainWindow`
#: MY_LANG="de_DE"
#: MY_MAP="IBM1132.gz"
#: EXIT="OK"

[ "$EXIT" = OK ] || continue
   [ "$MY_MAP" ] || continue
  [ "$MY_LANG" ] || continue

MAP=`echo "$MY_MAP" | sed 's%\..*$%%'`
echo "MAP=$MAP'"
echo "MY_LANG=$MY_LANG'"

localedef --no-archive -f $MAP -i $MY_LANG "${MY_LANG}.${MAP}" > $tmpDir/log/${MAP}.${MY_LANG}.log 2>&1
           RV=$?
echo "Return Value of localedef is < $RV >"

if [ "$RV" != 0 ] ; then
echo "$MY_LANG $MAP" >> /usr/share/i18n/UNSUPPORTED
ERROR_MSG=`tail -n 10 $tmpDir/log/"${MAP}.${MY_LANG}.log"`
xmessage -bg red "Failed to create correct Language

$ERROR_MSG"

cd /usr/lib/locale/
rmdir ${MY_LANG}*
cd "$start_dir"
exec $0

fi

grep "$MY_LANG" /usr/share/i18n/SUPPORTED | grep "$MAP" || echo "$MY_LANG $MAP" >> /usr/share/i18n/SUPPORTED

sed -i "s%^LANG=.*%LANG=${MY_LANG}\.${MAP}%" /etc/profile
[ $? = 0 ] || { xmessage -gb red "Sorry, probably /etc/profile corrupt."; exit 1; }

Xdialog --left --wrap --title "Glibc Locale setup" --ok-label "Restart X now" --cancel-label "Finished"  --yesno "Ok, the change has been made and will take effect at next boot. However, if you click the 'Restart X now' button X will exit then restart and the new locale will immediately take effect -- however make sure that all other applications are closed first as restarting X will rudely kill them! Otherwise, just click 'Finished' for the new locale to take effect at next boot.\n\nTechnical details:\nLocale files have been generated in /usr/lib/locale (if not already) and LANG variable set to ${MY_LANG}.${MAP} in /etc/profile." 0 100
 if [ $? -eq 0 ];then
  rm -rf /tmp/.X0-lock
  sync
  exec restartwm $CURRENTWM
 fi
 
done

No da_DE in i18n Rolling Eyes
chooselocale-1.01.png
 Description   try
French
or
Spanish
or
English
please
 Filesize   24.71 KB
 Viewed   481 Time(s)

chooselocale-1.01.png

Back to top
View user's profile Send_private_message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Sat 20 Apr 2013, 11:38    Post_subject:  

I don't think that da_DE or de_DK exists at this time .
Bonn-Kopenhagener Erklärungen

givt dat nich in inglisch .. Ick glööv dat jo nich !

Datts wegen die Englänners datt nich kennen, givt dat so veel Kriech inne Welt .

Jugoslawien wär jo een Exempel mit äner Vulksbefrugung ween west .. aver datt shall all so sien .
Back to top
View user's profile Send_private_message Visit_website 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Sat 20 Apr 2013, 11:48    Post_subject:  

LIDL Smile wrote:
Code:
<input>echo $MY_LANGUAGE; cat /tmp/AVAIL_LANGUAGES.lst</input>

Did not know that feature . Great Cool

And with fixmenus : it is ok , I like the loop reordering on first short sight,
but have mine with debugging output and would have been overwritten .

Have backups but lazy me needs to find the hdd somewhere , dig it out and climb under the table to attach it to the pc Mr. Green .

And sorry, this time i could not withstand: l18l and lidl ( you know . have no lidl near my place, mostly penny market man ) . Wink Smile

Nevertheless you make good batch of work , LIBL !
Back to top
View user's profile Send_private_message Visit_website 
Display_posts:   Sort by:   
Page 1 of 2 Posts_count   Goto page: 1, 2 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Advanced Topics » Puppy Projects » Localization Project
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.1345s ][ Queries: 13 (0.0097s) ][ GZIP on ]