gMeasures not working in localized Puppies [almost solved]

Stuff that has yet to be sorted into a category.
Message
Author
musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#21 Post by musher0 »

Moat wrote:
musher0 wrote:... but this version still offers only guilders as
a conversion from euros.
Ha - same here. I'm not even sure what a "guilder" is... :lol:

Bob
From http://dictionary.reference.com/browse/Guilder :
"a silver or nickel coin and monetary unit of the Netherlands until
the euro was adopted, equal to 100 cents"
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#22 Post by musher0 »

Hello, all.

As Mr. Kauler mentioned, gmeasures seems to be allergic to utf8...

Image

Image

Image

It doesn't care if LANG=en_CA or LANG=fr_CA, but it can't tolerate utf8!!!

Maybe the gtk-spin-button is making it dizzy!!!

All in the interest of science... :) BFN.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#23 Post by musher0 »

Hello, all.

Eureka! This is how to get gmeasures to show proper decimals in a
localized UTF-8 environment !

Create a new file gmeasures.sh in /usr/bin and make it executable.
Copy the following code from here and paste it in the new script. Save.

Code: Select all

#!/bin/ash
# /usr/bin/gmeasures.sh
# To get gmeasures to use decimals properly in a localized environment.
# musher0, March 6, 2015. 
# Thanks to BK for help in testing and for the hints.
# Discussion reference : http://murga-linux.com/puppy/viewtopic.php?t=98030
####
if [ "${LANG:6:5}" = "UTF-8" -o "${LANG:6:4}" = "utf8" ];then
	LANG="${LANG:0:5}"
	LANG="$LANG" gmeasures
	LANG="`awk -F"=" '$1=="LANG" { print $2 }' /etc/profile`"
	# We restore the original linguistic environment afterwards.
	# See /etc/profile, lines 99-104, if in doubt.
else
	gmeasures
fi
You'll also have to modify your gmeasures.desktop file at
/usr/share/applications, like so:

Code: Select all

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name=Gmeasures
Comment=Gmeasures weights and measures converter
Comment[fr]=Convertisseur de poids et mesures Gmeasures
Exec=gmeasures.sh
Icon=gmeasures.xpm
Terminal=false
Type=Application
Categories=Calculator
StartupNotify=true
GenericName=Units converter
If you prefer, you may manually change only the "Exec=" line,
from gmeasures to gmeasures.sh.

Result : we have proper decimals!!!

Image

Below, proof that UTF-8 has been restored: we can type fancy accented
vowels and characters in the last line after running gmeasures.
Image

I believe the above script should work with all UTF-8 locales? Please tell
me. Thanks in advance.

As to the euros to guilders conversion, I'll throw out there that someone
on the development team really loved his guilders -- more than euros--,
and was nostalgic? (Now where's that tongue-in-cheek icon...) ;)

Thanks everyone! :D

musher0
~~~~~~~~~
P.S. I'll wait for confirmation feedback before uploading a little *.pet
archive of this. Thanks in advance.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#24 Post by BarryK »

musher0,
No, that does not fix it.

I realised, soon after my last post, that I had made a mistake.

The problem is not UTF-8.

earlier I reported that this works, running robwoj44's binary:

# LANG=de_DE ./gmeasures

However, it doesn't. If there is no folder /usr/lib/locale/de_DE, then gmeasures falls back to using C locale.

So, it seems to have worked, but not really.

If you run quicksetup and choose de_DE, and untick the UTF-8 checkbox, then /usr/lib/locale/de_DE gets created.

Now run "LANG=de_DE ./gmeasures" and it doesn't work.

The C code needs to be fixed. Maybe robwoj44 will do that, I have informed him of the problem.
[url]https://bkhome.org/news/[/url]

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#25 Post by BarryK »

OK, I think that I have the solution.

The "gmeasureswrapper" script just needs this:

#!/bin/sh
LC_NUMERIC=C gmeasures

I am using robwoj44's binary.

I tried to put this into the C code, using setlocale(), but it doesn't work. So resorted to the above wrapper.
[url]https://bkhome.org/news/[/url]

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#26 Post by musher0 »

Thanks for sharing your thoughts and solutions about this problem, Barry.

It is true that the problem is not really one of localization by language,
but rather of the use of global standards: ISO vs "Imperial", for ex.
It's independent of linguistic maps.

I have some trouble understanding your argument on the impact of
existent or non-existent locale folders on decimals in the gmeasures
application. I'm sure I'll get there. The important thing is that a couple of
workarounds can now be offered to the user.

Perhaps robwoj44 could drop the euro<>guilder conversion altogether.
Currency rates change daily and perhaps should not be confused with
units conversions that are based on scientific constants. Just a thought.

The web is really well adapted to currency activity:
http://www.ask.com/web?qsrc=1&o=0&l=dir ... archTopBox

As I said earlier, I don't want to bang my head on this gmeasures any
longer. I have opted to use Puppy's good old pConvert for units, and
XE.com or a similar site if I ever need to know a daily exchange rate.

Best regards.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#27 Post by BarryK »

BarryK wrote:OK, I think that I have the solution.

The "gmeasureswrapper" script just needs this:

#!/bin/sh
LC_NUMERIC=C gmeasures

I am using robwoj44's binary.
robwoj44 has confirmed that this works, so this is the fix I will use in Quirky.
[url]https://bkhome.org/news/[/url]

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#28 Post by musher0 »

Sorry, wrong thread.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#29 Post by SFR »

BarryK wrote:OK, I think that I have the solution.

The "gmeasureswrapper" script just needs this:

#!/bin/sh
LC_NUMERIC=C gmeasures

I am using robwoj44's binary.

I tried to put this into the C code, using setlocale(), but it doesn't work. So resorted to the above wrapper.
Hey Barry & guys.

I was working on adding support for Kelvin degrees to gMeasures and stumbled across this thread.
Just letting you know that the 'setlocale()' hack works for me.
Well, it wasn't at first, when it was placed at the very beginning of main(), but I moved it below gtk_init(&argc, &argv); and it just started to work, dunno why actually.

The attached is the Kelvin patch (it's for the original sources, not Robwoj44's) that also contains the above fix (I'm too lazy to split it into 2 patches ;)).
The relevant lines are 172 & 248.

Greetings!
Attachments
gmeasures-kelvin.patch.tar.gz
(3.81 KiB) Downloaded 374 times
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

Post Reply