Re: NumberFormat and German Locale

2011-07-12 Thread tdk
ok, thanks everyone who contribute.

My conclusion is quite simple: since I only have a localized pattern,
I won't be able to use that and format the numbers acc. to it.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Aw: Re: NumberFormat and German Locale

2011-07-12 Thread Jens
NumberFormat.getDecimalFormat() just gives you a formatter using a default 
format string. If you want to use your own formatting string you have to use 
NumberFormat.getFormat(). In your case you have to use 
NumberFormat.getFormat("#,##0.0##"). The symbols "," and "." are special 
symbols used by the NumberFormat class for grouping and as decimal 
separator. You always have to use these symbols like they are defined in the 
JavaDoc for NumberFormat regardless of the target locale you want to use. 
The target locale is then responsible for changing "," and "." into the 
correct localized versions. For de_DE that would be "." for grouping 
(instead of the defined ",") and "," as decimal separator (instead of the 
defined ".").


-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/FkaVLeJKYbwJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: NumberFormat and German Locale

2011-07-12 Thread tdk


On 12 Jul., 10:26, Thomas Broyer  wrote:
> You're confusing the syntax of the pattern you give to NumberFormat for
> parsing, and then the use of that NumberFormat within the context of a
> locale.
> What you *give* to NumberFormat is locale-insensitive: #,##0.0##
> When you have that NumberFormat instance, what it does then depends on the
> current locale: when you format 1234.56 in the de_DE locale, you'll see (if
> I'm not mistaken) 1.234,56, in the fr_FR locale it'll be 1 234,56 and in the
> en_US locale it'll be 1,234.56.
ok, I think I understand what you are saying. But it's still a mystery
to me, how to tell the localized NumberFormat, e.g.
NumberFormat.getDecimalFormat(), to use ths user supplied pattern, eg
setting a certain precision, leading/trailing zeros, and such like.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: NumberFormat and German Locale

2011-07-12 Thread Thomas Broyer
You're confusing the syntax of the pattern you give to NumberFormat for 
parsing, and then the use of that NumberFormat within the context of a 
locale.
What you *give* to NumberFormat is locale-insensitive: #,##0.0##
When you have that NumberFormat instance, what it does then depends on the 
current locale: when you format 1234.56 in the de_DE locale, you'll see (if 
I'm not mistaken) 1.234,56, in the fr_FR locale it'll be 1 234,56 and in the 
en_US locale it'll be 1,234.56.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/1QXbOz75nHAJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: NumberFormat and German Locale

2011-07-11 Thread tdk
Tom, Rob,

thanx for this valuable information. That default is not "default" is
quite interesting, I wasn't aware of that.
But then the question is, how do I change the NumberFormat so that it
uses the set locale, eg de_DE, instead of "default"? I have not been
able to find/understand a way to do that. Maybe you can help me with
that...

The problem I have is that I can't use a fixed locale because my users
can change the language/locale on the fly. With the help of this and
other forums I found the way how to do that by reloading the app with
an "locale=de_DE" appended to the original URL. Not very nice and
elegant but it seems to be the only way. And as I mentioned in my OP
it actually works as far as the messages from GWT are concerned.

But what about NumberFormat (and DateFormat for that matter), how can
I change the default locale?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: NumberFormat and German Locale

2011-07-11 Thread Thomas Broyer
In a pattern, a dot is always the decimal separator and a comma always 
represents the thousands separator. When you render a number using the 
pattern, those separators might appear differently depending on the locale 
(e.g. the decimal separator being a comma and the thousands separator being 
a dot).

As Rob said, the default locale is not the "locale used by default", it's 
the locale called 'default' (Java would call it the 
ROOTlocale,
 and many systems call it 'C'; it is 
*not* 'en' though, even though it looks a lot like it).

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/-4XCY1-fqUQJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: NumberFormat and German Locale

2011-07-11 Thread Rob Coops
Default locale is actually default, not necessarily the local set.

I don't have access to my code at the moment so I'll have to do this from
the top of my head and without actually working code... but I'll give it a
try.

When a new user accesses the app I check the locale, to see what this is set
to, "default" or something else, if it is set to default then I force it to
the locale inferred by the user's IP address, if I have this local available
otherwise I set it to English.
There is such a thing as default in the list of locale's which usually is
_EN as far as I know.

I think what you are seeing is that the "default" locale you are using is
actually default (_EN) thus the number format is most likely set to
#,##0.0## instead of the #.##0,0## you are trying to use. I would suggest
simply telling the number formatter to use the _DE format (or simply the
same as the locale is set for for the user ;-)

Sorry for the lack of code, that the explanation is clear enough without it.

Regards,

Rob


On Mon, Jul 11, 2011 at 10:06 AM, tdk  wrote:

> I have severe problems, understanding and using
> com.google.gwt.i18n.client.Numberformat, hoping somebody out there can
> help and enlighten me.
>
> When I try to get a formatter via NumberFormat.getFormat(pattern) I
> get an InvalidPatternException even so my pattern is valid within the
> german locale, eg #.##0,0##.
> I know that the locale is set correctly and used by my app, because
> all the default texts, eg when loading data, show up in german.
>
> The documentation (and posts in various forms) say, that NumberFormat
> uses the default locale to get a formatter, with a specific pattern,
> which I assume in my case is de_DE, because it is set to this. So what
> am I doing wrong, am I missing?
>
> I'm using GWT 2.3
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to google-web-toolkit@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-toolkit+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



NumberFormat and German Locale

2011-07-11 Thread tdk
I have severe problems, understanding and using
com.google.gwt.i18n.client.Numberformat, hoping somebody out there can
help and enlighten me.

When I try to get a formatter via NumberFormat.getFormat(pattern) I
get an InvalidPatternException even so my pattern is valid within the
german locale, eg #.##0,0##.
I know that the locale is set correctly and used by my app, because
all the default texts, eg when loading data, show up in german.

The documentation (and posts in various forms) say, that NumberFormat
uses the default locale to get a formatter, with a specific pattern,
which I assume in my case is de_DE, because it is set to this. So what
am I doing wrong, am I missing?

I'm using GWT 2.3

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.