Bug 63075 - [PropertiesDialog] The file size in the file Properties dialog and the file Properties view is not formatted for the locale
Summary: [PropertiesDialog] The file size in the file Properties dialog and the file P...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M1   Edit
Assignee: Tod Creasey CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed, nl
Depends on:
Blocks:
 
Reported: 2004-05-19 15:13 EDT by Pixy CLA
Modified: 2007-08-07 09:55 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 Pixy CLA 2004-05-19 15:13:15 EDT
Eclipse build number: I200405140800
CDT build number: 200405121551
TestCase number: QE_TestCase_P1_I18N211, QE_TestCase_P1_I18N212

Test Case:
1. Change the locale to Spanish from control panel.
2. Restart eclipse & create a Java or C/C++ project. Create a file under the 
project and add code to it such that the file size exceeds 1000 bytes.
3. Right click on file and go to Properties. The file size specified there is 
not formatted according to the locale selected.
4. Go to Windows->Show view->Properties. The file size is not number formatted 
in the properties view for the locale as well.
Comment 1 Tod Creasey CLA 2004-05-19 15:34:14 EDT
We get this value from the virtual machine (Long.toString(localFile.length()) 
so the issue is with the virtual machine.
Comment 2 Tod Creasey CLA 2004-05-19 15:34:43 EDT
Marking WONTFIX as there is nothing we can do.
Comment 3 Tanya Wolff CLA 2004-05-19 16:18:37 EDT
The way numbers are displayed should pick up on the locale setting using Locale 
sensitive APIs. In Java, there are 2 ways: NumberFormat, or if the number is 
embedded in a string retrieved through a resource bundle, use MessageFormat.

Like this:
public class TestSize {

	public static void main(String[] args) {
		File localFile=new File ("test");
		long len = localFile.length();
		
		// use NumberFormat by itself
		NumberFormat nf = NumberFormat.getInstance();
		String lenStr=nf.format(len);
		System.out.println ("NumberFormat: "+ lenStr);
		
		// or we can mix NumberFormat with MessageFormat
		System.out.println ("MessageFormat: "+getFormattedString("key", 
new Long(len))); //$NON-NLS-1$
		
	}
	public static String getFormattedString(String key, Long arg) {
		return MessageFormat.format(getString(key), new Object[] { 
arg });
	}
	
	public static String getString (String key) {
		return ("The file size is: {0, number, integer} {0, choice, 
1#byte|2#bytes}");
	}
}


The output would then be (for US English locale): 
NumberFormat: 7,360
MessageFormat: The file size is: 7,360 bytes
Comment 4 Tod Creasey CLA 2004-05-19 16:27:11 EDT
Reopening to implement Tanyas suggestions.
Comment 5 Tod Creasey CLA 2007-06-26 16:14:30 EDT
Fixed in build >20070628. Thanks for the contribution Tanya.
Comment 6 Tod Creasey CLA 2007-08-07 09:55:25 EDT
Verified in  I20070807-0010