QuickLocaleSwitcher for people who have more than 1 langpack

For efforts in internationalising Puppy and solving problems in this area
Message
Author
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

QuickLocaleSwitcher for people who have more than 1 langpack

#1 Post by L18L »

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 :D

[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]
Attachments
quicklocaleswitch-0.4.pet
(4 KiB) Downloaded 592 times
quicklocaleswitch-0.3.pet
(3.85 KiB) Downloaded 658 times
QuickLocaleSwitch_0.3_en.png
(22.49 KiB) Downloaded 723 times
quicklocaleswitch-0.2.pet
(3.72 KiB) Downloaded 676 times
QuickLocaleSwitch_0.2_ru.png
quick switch between Russian and German
(59.16 KiB) Downloaded 726 times
quicklocaleswitch-0.1.pet
(3.49 KiB) Downloaded 711 times
quickLocaleSwitch.png
(35.82 KiB) Downloaded 864 times
Last edited by L18L on Fri 04 Apr 2014, 17:42, edited 15 times in total.

User avatar
Bert
Posts: 1103
Joined: Fri 30 Jun 2006, 20:09

#2 Post by Bert »

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!.
[url=http://pupsearch.weebly.com/][img]http://pupsearch.weebly.com/uploads/7/4/6/4/7464374/125791.gif[/img][/url]
[url=https://startpage.com/do/search?q=host%3Awww.murga-linux.com%2F][img]http://i.imgur.com/XJ9Tqc7.png[/img][/url]

User avatar
vicmz
Posts: 1262
Joined: Sun 15 Jan 2012, 22:47

#3 Post by vicmz »

Cool 8)
I'd like to learn German, Japanese, Chinese, and Korean.
[url=http://murga-linux.com/puppy/viewtopic.php?t=76948]Puppy Linux en español[/url]

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

learning German

#4 Post by L18L »

vicmz wrote:Cool 8)
I'd like to learn German, ...
Nivel principiante :?:
http://lp.babbel.com/d/SPA_tutorial.htm ... ner&ch=ORG :idea:

[edit] returning now from 1st lesson of learning Dutch for Espanols :lol:

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

QuickLocaleSwitcher

#5 Post by L18L »

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: Select all

QuickLocaleSwitch
then you will see how many ( :?: ) 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: Select all

ls /usr/local/bin/default*
I have changed their code for example for defaultcalendar from

Code: Select all

#!/bin/sh
osmo $@
to

Code: Select all

#!/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:
Attachments
osmo_nl_de.png
Exemple for
One app in 2 different locales active
(8.99 KiB) Downloaded 899 times

User avatar
vicmz
Posts: 1262
Joined: Sun 15 Jan 2012, 22:47

#6 Post by vicmz »

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

http://ocw.mit.edu/resources/res-21f-00 ... ssons-1-3/
[url=http://murga-linux.com/puppy/viewtopic.php?t=76948]Puppy Linux en español[/url]

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#7 Post by Karl Godt »

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 :
Attachments
chooselocale-table.jpg
(55.94 KiB) Downloaded 769 times

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#8 Post by Karl Godt »

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 !

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#9 Post by Karl Godt »

Got it, when only two languages then comes no gui . gui missing ut8 or not utf8 mentioning .
Attachments
QLS.jpg
(21.13 KiB) Downloaded 817 times

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

QuickLocaleSwitcher

#10 Post by L18L »

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.

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

#11 Post by L18L »

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!

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#12 Post by Karl Godt »

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: Select all

#!/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

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

chooselocale

#13 Post by L18L »

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: Select all

#!/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 :roll:
Attachments
chooselocale-1.01.png
try
French
or
Spanish
or
English
please
(24.71 KiB) Downloaded 781 times

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#14 Post by Karl Godt »

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 .

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#15 Post by Karl Godt »

LIDL :) wrote:

Code: Select all

<input>echo $MY_LANGUAGE; cat /tmp/AVAIL_LANGUAGES.lst</input>
Did not know that feature . Great 8)

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 :mrgreen: .

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

Nevertheless you make good batch of work , LIBL !

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

#16 Post by L18L »

build de_DK and da_DE from /usr/share/i18n/locales
.. Ick glööv dat jo
Karl Godt wrote:Did not know that feature . Great 8)
... and I did not know that:

Code: Select all

grep -viE 'posix|translit|i18n|iso|eur|^$' 
:D

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

QuickLocaleSwitcher

#17 Post by L18L »

AppInfo.xml in langpack has to be reorganized to enable multi-lingual use
bi-lingual is OK if one of the two is English

But I want real multi-lingual use.
example trash

Code: Select all

<?xml version="1.0"?>
<AppInfo>
  <Summary>Trash</Summary>
  <Summary xml:lang="ru">Корзина</Summary>
  <Summary xml:lang="ja">ゴミ箱</Summary>
  <Summary xml:lang="zh_CN">回收站</Summary>
  <About>
    <Purpose>Trash Can for Puppy Linux</Purpose>
    <License>GPL: http://www.gnu.org/licenses/gpl.txt</License>
    <Version>0.3.2 - September 04, 2008</Version>
    <Homepage>http://murga-linux.com/puppy/viewtopic.php?t=27310/</Homepage>
  </About>
  <AppMenu>
	<Item option="-look">
	<Label>Look in the Trash</Label>
	<Label xml:lang="ru">По

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

QuickLocaleSwitcher

#18 Post by L18L »

L18L wrote:...Solution,
- fix momanager
#130418 rename AppInfo.xml to AppInfo.xml.in for langpack to enable peaceful co-existences of langpacks for different languages L18L

- fix pinstall.sh
#130420 merge AppInfo.xml.in with AppInfo.xml to enable peaceful coexistence of multiple langpacks

.....coming tomorrow :lol:
Here it is in attached create_langpack_for_multiple_languages.tar.gz
which contains
-momanager
-pinstall_hacks.sh

If you create a langpack after having installed this ( just expand it to / )
then this langpack does not overwrite the AppInfo.xml files
but merge the xml:lang=..

I should create a new langpack_de soon
... and wait for others?
or if you do not have a fast and cheap ( zero cost ) connection
then tell me and I can switch your langpack for multilingual usage .... :wink:
Attachments
create_langpack_for_multiple_languages.tar.gz
expand to /
and create new langpack
which is multi-lingual friendly
(20.85 KiB) Downloaded 780 times

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

QuickLocaleSwitcher

#19 Post by L18L »

L18L wrote:...I should create a new langpack_de soon....
Creation was quickly done.
But upload to ompl.org failed....

Try this one please: [edit] URL changed to official langpack [/edit]
http://distro.ibiblio.org/quirky/pet_pa ... 130528.pet
Last edited by L18L on Sat 08 Jun 2013, 10:31, edited 1 time in total.

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

#20 Post by L18L »

Karl Godt wrote: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 !
dat givt in spanisch
vicmz is very busy :lol:

Post Reply