Following up on shell(locale) problem
Mike Bonner
bonnmike at gmail.com
Tue Mar 1 20:42:19 EST 2011
Yeah, was just pointing out that since os x has python installed by default
(right?) could include a small python script and just feed it numbers
through shell anytime you wanted a currency format. Not sure how fast it
would be for lots of conversions though. /shrug
On Tue, Mar 1, 2011 at 6:37 PM, Peter Haworth <pete at mollysrevenge.com>wrote:
> Thanks Mike. I'm glad to hear there is a programming language out there
> that actually uses the locale information. Unfortunately, there isn;t
> anything in LiveCode, for numbers and currency that is.
>
>
> Pete Haworth
>
>
> On Mar 1, 2011, at 4:52 PM, Mike Bonner wrote:
>
> > Well if you can figure out how to get locale to work from an lc shell,
> there
> > are interesting things that can be done in that vein using python.
> >
> > If LANG is set to en_GB, and locale is actually working, you can feed it
> to
> > a python script such as this
> >
> > #!/usr/bin/python
> > import locale -- for locale stuff of course
> > import sys -- so we can get argv
> > tVal = float(sys.argv[1]) -- sets argv[1] type to float and puts in tval
> > locale.setlocale(locale.LC_ALL, ' ' ) -- assuming all is perfect *cough*
> > grabs the locale
> > tOut = locale.currency(tVal,1,1,0)
> >
> > -- puts out the number with adjustements. tVal is passed number, next is
> > whether to show or not show the symbol, next is grouping on or off, next
> is
> > use international symbol, or not. So, if LANG is set to en_GB you get
> back
> > the great brit symbol, groups of 3, seperated by comma with a "."
> decimal.
> >
> > As you say though, not sure it'ts worth the effort, can just ask the
> user.
> >
> > If you're curious, I got this info from
> > http://docs.python.org/library/locale.html
> >
> > On Tue, Mar 1, 2011 at 5:24 PM, Peter Haworth <pete at mollysrevenge.com
> >wrote:
> >
> >> Thanks Mike. 'Fraid the command you gave me still returns the incorrect
> >> info when executed with the LC shell command.
> >>
> >> In answer to your other email, I'm trying to get this info so I can
> format
> >> numbers and currency in my application according to the user's
> preferences,
> >> rather than having the user specify the same preferences to my
> application.
> >> But it's quickly becoming more trouble than it's worth!
> >>
> >>
> >> Pete Haworth
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> http://www.mollysrevenge.com
> >> http://www.sonicbids.com/MollysRevenge
> >> http://www.myspace.com/mollysrevengeband
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> On Mar 1, 2011, at 4:04 PM, Mike Bonner wrote:
> >>
> >>> Ok, while this doesn't solve the issue, if you do
> >>>
> >>> shell("LANG=en_US.UTF-8;locale -k LC_NUMERIC")
> >>>
> >>> You get back the correct info yes?
> >>>
> >>> The problem here is that (I think someone said this farther up) the
> >> process
> >>> shell uses isn't the same as a full blown terminal start. If you have a
> >>> .bash_profile file in your user directory, and you do
> >>>
> >>> shell("source ~/.bash_profile ; locale -k LC_MONETARY") does it work?
> >>>
> >>> On Tue, Mar 1, 2011 at 4:48 PM, Peter Haworth <pete at mollysrevenge.com
> >>> wrote:
> >>>
> >>>> OK, In terminal, that returns "LANG=en_US.UTF-8". With the LC shell
> >>>> command, it returns nothing!! There's definitely something weird
> going
> >> on
> >>>> with the LC shell command.
> >>>>
> >>>> Pete Haworth
> >>>>
> >>>> On Mar 1, 2011, at 2:44 PM, Mike Bonner wrote:
> >>>>
> >>>>> I'd still be curious to know if
> >>>>> env; |grep LANG
> >>>>>
> >>>>> returns the same environment variable value both from LC shell, and
> >> from
> >>>>> terminal
> >>>>
> >>>>
> >>>> _______________________________________________
> >>>> use-livecode mailing list
> >>>> use-livecode at lists.runrev.com
> >>>> Please visit this url to subscribe, unsubscribe and manage your
> >>>> subscription preferences:
> >>>> http://lists.runrev.com/mailman/listinfo/use-livecode
> >>>>
> >>> _______________________________________________
> >>> use-livecode mailing list
> >>> use-livecode at lists.runrev.com
> >>> Please visit this url to subscribe, unsubscribe and manage your
> >> subscription preferences:
> >>> http://lists.runrev.com/mailman/listinfo/use-livecode
> >>>
> >>
> >>
> >> _______________________________________________
> >> use-livecode mailing list
> >> use-livecode at lists.runrev.com
> >> Please visit this url to subscribe, unsubscribe and manage your
> >> subscription preferences:
> >> http://lists.runrev.com/mailman/listinfo/use-livecode
> >>
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> >
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
More information about the use-livecode
mailing list