Bug 91360 - [Widgets] Spinner should support I18N
Summary: [Widgets] Spinner should support I18N
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: api, triaged
Depends on:
Blocks:
 
Reported: 2005-04-13 21:14 EDT by Rod Bailey CLA
Modified: 2017-07-11 09:58 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rod Bailey CLA 2005-04-13 21:14:13 EDT
Formatting of numbers differs between locales. Sometimes a "," is used instead 
of a "." as the decimal separator. Sometimes thousands are separated by a " " 
and other times by a "," and so on.

These formatting differences are known to java.text.NumberFormat. It would be 
very useful for the Spinner widget to incorporate some I18N facility that 
allows specification of a NumberFormat. This would also allow the Spinner to 
handle currency values and the like.
Comment 1 Felipe Heidrich CLA 2005-04-14 12:13:25 EDT
Spinner uses the correct decimal separator for the current locale, "." on 
english, "," in portuguese, etc.

Are you asking API to set the decimal separator? For example, to force "," to 
be used instead of "." in English ?
Comment 2 Rod Bailey CLA 2005-04-14 20:39:48 EDT
> Are you asking API to set the decimal separator? For 
> example, to force "," to be used instead of "." in English ?

No. Just the correct formatting for the current locale is fine. Does the 
existing behaviour mean that the "thousands" separator will also be correct 
for the current locale. eg. will one thousand two hundred thirty four appear 
as either "1234", "1 234" or "1,234" depending upon locale? Can I turn 
off "thousands" separators altogether? 

For me, the best solution would be one that allows me to specify an instance 
of java.text.NumberFormat that the Spinner will use to format its current 
value for display. eg. add the following to the spinner's api:

public void setNumberFormat(java.text.NumberFormat format);

Generally I would pass in the NumberFormat instances supplied by the 
getNumberInstance(), getPercentInstance() and getCurrencyInstance() factory 
methods of NumberFormat.

With such a facility, I could use spinners to set percentages and currency 
values in an internationalizable way (both of which would be great in the SWT 
application I'm currently working on).
Comment 3 Felipe Heidrich CLA 2005-04-15 11:45:57 EDT
Sorry Rob, Spinner doesn't have thousands separator, only decimal separator 
(used when running on float point mode, by calling setDigits()).
Comment 4 Daniel Krügler CLA 2005-05-04 07:34:57 EDT
I noticed the same deficiency of Spinner (in floating-point mode) as the OP. I
think the needs are real: Quite often applications need to run in given locale,
independent of the "native" or "natural" locale of the OS (which seems to fix
the appearance of the decimal separator of the Spinner widget). For every
observable UI elements I am aware of (Please correct me, if I am wrong), this is
easily done by setting the applications's locale (via start parameters).
Regrettably Spinner is an exception here. I propose one of the following options:

1) Take full local information of number formats into account (i.e. including
thousand separator and others) and provide an getter/setter interface in Spinner
which allows setting the NumberFormat or Locale. Although this seems the most
complete solution it will cause backward-compatibility problems (at least if
those are not viewed as bugs, which need fixing)

2) A minimum solution which would not seem to cause any harm would be the
addition of a simple setter function namely

void Spinner.setDecimalSeparator(char newSeparator);

which conforms to the java.text.DecimalFormatSymbols interface.
Comment 5 Felipe Heidrich CLA 2005-07-26 15:28:41 EDT
see Bug 103127 
Comment 6 Felipe Heidrich CLA 2009-08-19 08:47:35 EDT
Your bug has been moved to triage, visit http://www.eclipse.org/swt/triage.php for more info.