[SOLVED] Current language while installing application?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

[SOLVED] Current language while installing application?

#1 Post by Argolance »

Hello,
I created a pinstall.sh file that should be displayed in French or in English while installing my application:

Code: Select all

#!/bin/sh

# Toutou LINUX delete/replace obsolete scripts if present and create link from old to new script...

# set locale
LNG=$(echo $LANG|cut -d':' -f1)
LOCALE=$(echo $LNG|cut -d'_' -f1)

if [ $LOCALE != "fr" ];then

echo "English_text"
...
else
echo "French_text"
...
fi
exit 0
... This works quite well when pinstall.sh is launched for testing but doesn't while installing :shock: !

What's going wrong?

Regards.
Last edited by Argolance on Mon 25 Apr 2011, 14:10, edited 1 time in total.

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#2 Post by 01micko »

Barry changes the $LANG environment variable when running petget.

I suppose you need a work around for that somehow..

The current variable for LANG is LANG=C (when petget is running), so you would need to override this.

Maybe this at top of your pinstall.sh: (note the dot)

Code: Select all

. /etc/profile
which should set all environment variables back to defaults.

Hopefully that would work.

A simple test is to put "xmessage $LANG" in your pinstall script, you will then see the output is "C".
Puppy Linux Blog - contact me for access

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#3 Post by Argolance »

Hello,
Looking inside the /etc/profile file, I noticed these lines:

Code: Select all

#this line gets edited by chooselocale script...
#LANG=fr_FR.utf8 w004 going back to non-utf8...
LANG=fr_FR
export LANG
LC_ALL=fr_FR
export LC_ALL
LANGUAGE=fr_FR
export LANGUAGE
But are these lines present in all Puppy /etc/profile files?
I modified my pinstall.sh this way:

Code: Select all

# set locale
LNG=$(echo $LANGUAGE|cut -d':' -f1)
LOCALE=$(echo $LNG|cut -d'_' -f1)
... and this seems to solve the problem...
But is it enough or should I do exactly what you wrote?

Thank you.
Regards

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#4 Post by Argolance »

Maybe this at top of your pinstall.sh: (note the dot)

Code: Select all

. /etc/profile
which should set all environment variables back to defaults.
This seems to work well too...
I'll choose this one that is probably running for certain!

Regards!
Last edited by Argolance on Mon 25 Apr 2011, 14:07, edited 1 time in total.

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#5 Post by Argolance »

Found this too:

Code: Select all

# set locale (from simple localization for scripts by Shinobar based on MU).

for LNG in C $(echo $LANGUAGE|cut -d':' -f1) $LC_ALL $LANG;do :;done
LOCALE=$(echo $LNG|cut -d'_' -f1)
Regards.

Post Reply