1. locale support?

I finished documenting datetime.e:

http://jeremy.cowgar.com/euphoria/lib_dtm.htm

And it has a format function that allows you to:

d = new(2008, 5, 2, 12, 58, 32)
s = format(d, "%A, %B %d '%y %H:%M%p")
-- s is "Friday, May 2 '08 12:58PM"


So, the problem is not that the format function cannot support other languages
(because it can), but how to deal with locale support. Right now, in datetime.e
there are a few sequences titled things like: month_names, month_abbrs,
day_names, day_abbrs. Those are global sequences that format() uses to populate
the resulting string with.

If you do not speak English, you can easily change the content of those global
sequences and format will happily use your language to format the date/time.
However, do we need a greater support? i.e. should I introduce a locale.e or
something?

For instance, the GNU C locale support has abilities for dates, times, numbers,
money, etc...

--
Jeremy Cowgar
http://jeremy.cowgar.com

new topic     » topic index » view message » categorize

2. Re: locale support?

Yes, it would be great if the app could use format dates, times, etc. according
to the OS settings.

~Ryan W. Johnson

Fluid Application Environment
http://www.fluidae.com/

[cool quote here, if i ever think of one...]

new topic     » goto parent     » topic index » view message » categorize

3. Re: locale support?

> On 2 May 2008 at 10:18, Jeremy Cowgar wrote (maybe snipped):

> 
> 
> posted by: Jeremy Cowgar <jeremy at c??gar.com>
> 
> I finished documenting datetime.e:
> 
> http://jeremy.cowgar.com/euphoria/lib_dtm.htm
> 
> And it has a format function that allows you to:
> 
> }}}
<eucode>
> d = new(2008, 5, 2, 12, 58, 32)
> s = format(d, "%A, %B %d '%y %H:%M%p")
> -- s is "Friday, May 2 '08 12:58PM"
> </eucode>
{{{

> 
> So, the problem is not that the format function cannot support other
> languages (because it can), but how to deal with locale support. Right
> now, in datetime.e there are a few sequences titled things like:
> month_names, month_abbrs, day_names, day_abbrs. Those are global
> sequences that format() uses to populate the resulting string with.
> 
> If you do not speak English, you can easily change the content of
> those global sequences and format will happily use your language to
> format the date/time. However, do we need a greater support? i.e.
> should I introduce a locale.e or something?
> 
Definitely, yes! I fully support the motion and I'm voluteering to do 
my part in translation. All I need is original text in English and 
commenting for disambiguation.

Question: would namespace be applicable here? So...

d = br:new(2008, 5, 2, 12, 58, 32)
s = format(d, "%A, %d de %B de %Y %H:%M")
-- s is "Sexta, 2 de Maio de 2008 12:58"


Best,
Euler

-- 
_
_| euler f german
_| sete lagoas, mg, brazil
_| efgerman{AT}gmail{DOT}com
_| -----------------------------
_| Reply preferably to the list,
_| or to the address above. Thx!

new topic     » goto parent     » topic index » view message » categorize

4. Re: locale support?

I was originally thinking of providing a 100% euphoria solution, however, there
are a lot of locales! So, I started in Linux, wrapped setlocale, strfmon and
strftime. This gives us complete locale support in linux. You can use *any*
locale that the user has installed. It'll format dates, times, currency and
numbers according to that locale:

include locale.e as l
include datetime.e as d

d:datetime now
now = d:now()

l:set("en_US")
printf(1, "%s, %s, %s\n", {
    l:datetime("%A, %B  %d %Y", now),
    l:money(10928.2),
    l:number(1029.35)})


Output is:

Sunday, May 4 2008, $10,928.20, 1,029.35

You can set any locale and the date language will change, the currency symbol,
the thousands and decimal point, etc... The final


There are two more things to do:

1. make it work in Windows, see: http://www.openeuphoria.org/EUforum/m20366.html

2. Message localization. My ideas here are to provide .ini files
(cross-platform) to provide localization files:

data/en_US.ini
data/en_CA.ini
etc...

HELLO=Hello
WORLD=World
GREETING=%s, %s!
ERROR=Error: %i %s
ERR_FILE_OPEN=%s could not be opened

include locale.e as l

l:set({"en_US", "data"})
puts(1, l:tr("$GREETING", {l:w("HELLO"), l:w("WORLD")}))
puts(1, l:tr("$GREETING", {l:w("HELLO"), "John"}))
puts(1, l:tr("$ERROR", {10, l:w("ERR_FILE_OPEN"), filename}))


Since you use the tr and w functions often, they are tiny. tr = translate, w =
word or lookup word.

Anyway that's where I am at. Any thoughts?

--
Jeremy Cowgar
http://jeremy.cowgar.com

new topic     » goto parent     » topic index » view message » categorize

5. Re: locale support?

Ok, locale support now works on Windows and Linux. Please see my problem at the
end of this message.

include locale.e as l
include datetime.e as d
 
d:datetime now
now = d:now()
 
l:set("en_US")
printf(1, "%s, %s, %s\n", {
    l:datetime("%A, %B  %d %Y", now),
    l:money(10928.2),
    l:number(1029.35)})


Output is:

Sunday, May 4 2008, $10,928.20, 1,029.35
 
You can set any locale and the date language will change, the currency symbol,
the thousands and decimal point, etc... The best part is it uses OS dependent
locale data so we do not have to manage locale data, have to do no translations,
and Euphoria can now be set for any locale that a user happens to have installed.

========
Problem
========

Locale names are different on Linux and Windows. For instance, to get the locale
for United States English, on Windows you must:

l:set("English_United States")


however, under Linux you must:

l:set("en_US")


Creating a cross-walk may not be that easy but if we have to, it's still easier
than translating hundreds of locales to pure Euphoria.

So. Any suggestions/thoughts? 

--
Jeremy Cowgar
http://jeremy.cowgar.com

new topic     » goto parent     » topic index » view message » categorize

6. Re: locale support?

Well, the Linux stuff should be Posix, but if nothing else then I guess you have
to wrap it in a platform() test.

Are there posix-compatible functions in msvcrt.dll?

--
A complex system that works is invariably found to have evolved from a simple
system that works.
--John Gall's 15th law of Systemantics.

"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare

j.

new topic     » goto parent     » topic index » view message » categorize

7. Re: locale support?

Jason Gade wrote:
> 
> Well, the Linux stuff should be Posix, but if nothing else then I guess you
> have to wrap it in a platform() test.
> 
> Are there posix-compatible functions in msvcrt.dll?
> 

Yes, I had a bit of trouble tracking down GetCurrencyFormatA, but finally got
it. So, we now have locale support in Windows and Linux/FreeBSD. However, I still
have this problem:

http://www.openeuphoria.org/EUforum/m20384.html

--
Jeremy Cowgar
http://jeremy.cowgar.com

new topic     » goto parent     » topic index » view message » categorize

8. Re: locale support?

Jeremy Cowgar wrote:
> 
> Ok, locale support now works on Windows and Linux. Please see my problem at
> the end of this message.

I notice some oddities about locale.e that were probably left in by
mistake.  For instance, your platform error message references IUp.
Also, the setlocale and strftime imports aren't within the LINUX/BSD
platform guards.

More on topic, I thought Windows used LCIDs, which are numbers, rather than
strings, to denote specific locales.

Matt

new topic     » goto parent     » topic index » view message » categorize

9. Re: locale support?

Matt Lewis wrote:
> 
> Jeremy Cowgar wrote:
> > 
> > Ok, locale support now works on Windows and Linux. Please see my problem at
> > the end of this message.
> 
> I notice some oddities about locale.e that were probably left in by
> mistake.  For instance, your platform error message references IUp.

Ops! That's what you get for copy/paste to saving time smile I've corrected it in
my copy. It'll be in my next commit.

> Also, the setlocale and strftime imports aren't within the LINUX/BSD
> platform guards.

They are the same function on both Windows and Unix systems.

> 
> More on topic, I thought Windows used LCIDs, which are numbers, rather than
> strings, to denote specific locales.
> 

The setlocale function works the same in Windows as in Linux, it just takes
different Locale names. I am no locale expert, but that's what I understand from
the docs.

--
Jeremy Cowgar
http://jeremy.cowgar.com

new topic     » goto parent     » topic index » view message » categorize

10. Re: locale support?

Jeremy Cowgar wrote:
> 
> Ok, locale support now works on Windows and Linux. Please see my problem at
> the end of this message.
> 
> }}}
<eucode>
> include locale.e as l
> include datetime.e as d
>  
> d:datetime now
> now = d:now()
>  
> l:set("en_US")
> printf(1, "%s, %s, %s\n", {
>     l:datetime("%A, %B  %d %Y", now),
>     l:money(10928.2),
>     l:number(1029.35)})
> </eucode>
{{{

> 
> Output is:
> 
> Sunday, May 4 2008, $10,928.20, 1,029.35
>  
> You can set any locale and the date language will change, the currency symbol,
> the thousands and decimal point, etc... The best part is it uses OS dependent
> locale data so we do not have to manage locale data, have to do no
> translations,
> and Euphoria can now be set for any locale that a user happens to have
> installed.
> 
> ========
> Problem
> ========
> 
> Locale names are different on Linux and Windows. For instance, to get the
> locale
> for United States English, on Windows you must:
> 
> }}}
<eucode>
> l:set("English_United States")
> </eucode>
{{{

> 
> however, under Linux you must:
> 
> }}}
<eucode>
> l:set("en_US")
> </eucode>
{{{

> 
> Creating a cross-walk may not be that easy but if we have to, it's still
> easier
> than translating hundreds of locales to pure Euphoria.
> 
> So. Any suggestions/thoughts? 
> 
> --
> Jeremy Cowgar
> <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a>


global sequence LANG_US

if platform() = 2 then
LANG_US = "English_United States"
elsif platform() = 3 then
LANG_US = "en_US"
end if


Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

new topic     » goto parent     » topic index » view message » categorize

11. Re: locale support?

Bernie Ryan wrote:
>  
> global sequence LANG_US
> 
> if platform() = 2 then
> LANG_US = "English_United States"
> elsif platform() = 3 then
> LANG_US = "en_US"
> end if
> </eucode>
{{{

> 

I'd hate to have each programmer have to manage the cross-walk though for each
locale. On my Linux box there are 373 locales. So, inside of each platform()
check, you would then have to choose between 373 different locales. Now, some of
those have multiple encodings to them, such as ASCII and UTF-8. But still, it's
in the range of 200 or so.

I am unsure how many locales Windows has and really not even sure how to figure
it out.

--
Jeremy Cowgar
http://jeremy.cowgar.com

new topic     » goto parent     » topic index » view message » categorize

12. Re: locale support?

http://www.cryer.co.uk/brian/windows/info_windows_locale_table.htm

So, "en-US" doesn't work for Windows? I was looking around for locale info and
from what I saw it should.

Also it looks like msvcrt.dll does contain setlocale.

--
A complex system that works is invariably found to have evolved from a simple
system that works.
--John Gall's 15th law of Systemantics.

"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare

j.

new topic     » goto parent     » topic index » view message » categorize

13. Re: locale support?

Jason Gade wrote:
> 
> <a
> href="http://www.cryer.co.uk/brian/windows/info_windows_locale_table.htm">http://www.cryer.co.uk/brian/windows/info_windows_locale_table.htm</a>
> 
> So, "en-US" doesn't work for Windows? I was looking around for locale info and
> from what I saw it should.

That's a nice list. en-us, en-US and en_US do not work. English, English_United
States, English_United States.1252 all work.
 
> Also it looks like msvcrt.dll does contain setlocale.

Yes, I am using that currently for the setlocale implementation on Windows.

--
Jeremy Cowgar
http://jeremy.cowgar.com

new topic     » goto parent     » topic index » view message » categorize

14. Re: locale support?

What about something like this:

integer PLATFORM

PLATFORM = platform()

sequence languages
   languages = {
                { "English", {"", "English_US", "en_US" }}
                ...
               }

l:set("English",languages[PLATFORM])


or from an ini file of similar format.

new topic     » goto parent     » topic index » view message » categorize

15. Re: locale support?

Jeremy Cowgar wrote:
> 
> Jason Gade wrote:
> > 
> > <a
> > href="http://www.cryer.co.uk/brian/windows/info_windows_locale_table.htm">http://www.cryer.co.uk/brian/windows/info_windows_locale_table.htm</a>
> > 
> > So, "en-US" doesn't work for Windows? I was looking around for locale info
> > and
> > from what I saw it should.
> 
> That's a nice list. en-us, en-US and en_US do not work. English,
> English_United
> States, English_United States.1252 all work.
>  
> > Also it looks like msvcrt.dll does contain setlocale.
> 
> Yes, I am using that currently for the setlocale implementation on Windows.
> 
> --
> Jeremy Cowgar
> <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a>

Why not:
* convert the list linked above, or the one at 
http://msdn.microsoft.com/en-us/library/ms776260(VS.85).aspx
into two maps, the common key eing the LCID;
* Then, when user provides a string for a locale, look it up the appropriate
map, chosen by a call to platform().

CChris

new topic     » goto parent     » topic index » view message » categorize

16. Re: locale support?

Jeremy Cowgar wrote:
> 
> Jason Gade wrote:
> > 
> > <a
> > href="http://www.cryer.co.uk/brian/windows/info_windows_locale_table.htm">http://www.cryer.co.uk/brian/windows/info_windows_locale_table.htm</a>
> > 
> > So, "en-US" doesn't work for Windows? I was looking around for locale info
> > and
> > from what I saw it should.
> 
> That's a nice list. en-us, en-US and en_US do not work. English,
> English_United
> States, English_United States.1252 all work.
>  
> > Also it looks like msvcrt.dll does contain setlocale.
> 
> Yes, I am using that currently for the setlocale implementation on Windows.
> 
> --


Jeremy:

You only need two strings for the English language standard library.

One for Windows and  one for Linux.

Your standard libraries are only good for english.

If a user is using MS windows in a different language then your

complete standard library will have to be translated.

Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

new topic     » goto parent     » topic index » view message » categorize

17. Re: locale support?

Bernie Ryan wrote:
> 
> You only need two strings for the English language standard library.
> One for Windows and  one for Linux.
> Your standard libraries are only good for english.
> If a user is using MS windows in a different language then your
> complete standard library will have to be translated.
>

I'm not sure what you mean? The standard libraries will work in many, many
languages. Some languages might might have to use UTF-8 or possibly UTF-16
encoding, but it should not be a big deal.

What do you mean they will only work in English?

--
Jeremy Cowgar
http://jeremy.cowgar.com

new topic     » goto parent     » topic index » view message » categorize

18. Re: locale support?

Jeremy Cowgar wrote:
> 
> Bernie Ryan wrote:
> > 
> > You only need two strings for the English language standard library.
> > One for Windows and  one for Linux.
> > Your standard libraries are only good for english.
> > If a user is using MS windows in a different language then your
> > complete standard library will have to be translated.
> >
> 
> I'm not sure what you mean? The standard libraries will work in many, many
> languages.
> Some languages might might have to use UTF-8 or possibly UTF-16 encoding, but
> it should not be a big deal.
> 
> What do you mean they will only work in English?
> 
> --


Jeremy:

What about error messages, text in sequences, function/procedure names ?

That is why Windows uses resource files they contain string tables

that are compiled for different languages.

Look at Igor's site:

http://www.rapideuphoria.com/russian/index_r.htm

Which is not in English.

Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

new topic     » goto parent     » topic index » view message » categorize

19. Re: locale support?

Bernie Ryan wrote:
> 
> 
> What about error messages

Those are very few, and at that, there are many, many, many more that exist in
Euphoria itself. Euphoria itself is not localized.

> text in sequences

That is what locale.e's po_load() and w() functions are for. It allows the
programmer to localize their own application.

> function/procedure names ?

I'm not aware of any programming language that translates function names to new
languages. In that area, it's still an English speaking world and it is a
non-issue.

> That is why Windows uses resource files they contain string tables
> that are compiled for different languages.

Yes. Euphoria has that now with .po files. .po is a very popular format for
localization. There are many GUI based translation software packages to work with
the .po file, or you can use a normal text editor for that task.
 
> Look at Igor's site:

Yup. That's not a problem with the new locale.e. Did you look at any of my
examples?

--
Jeremy Cowgar
http://jeremy.cowgar.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu