I read the current Locale settings on the computer and set the language (properties) file to converting my application to be used on different Locales. This is being done by reading the current regional settings on Windows. On MAC OS, when the jar file is run, it always detects the Locale as en_US and therefore shows the USD as currency and US English as default language. The code that we are running for testing is:
Locale lclLanguage; lclLanguage = new Locale(Locale.getDefault().getLanguage(),Locale.getDefault().getCountry()); String strNumberFormat = NumberFormat.getCurrencyInstance(lclLanguage).getCurrency().getSymbol(lclLanguage); JOptionPane.showMessageDialog(null, "Number format: " + strNumberFormat); ResourceBundle rbLangBundle = null; JOptionPane.showMessageDialog(null, "Country: " + lclLanguage.getCountry() + "\r\n" + "Display country: " + lclLanguage.getDisplayCountry() + "\r\n" + "Display Language: " + lclLanguage.getDisplayLanguage() + "\r\n" + "Display name: " + lclLanguage.getDisplayName() + "\r\n" + "Display variant: " + lclLanguage.getDisplayVariant() + "\r\n" + "ISO3Country: " + lclLanguage.getISO3Country() + "\r\n" + "ISO3language: " + lclLanguage.getISO3Language() + "\r\n" + "Language: " + lclLanguage.getLanguage() + "\r\n" + "Variant: " + lclLanguage.getVariant()); rbLangBundle = ResourceBundle.getBundle("MessagesBundle", lclLanguage); JOptionPane.showMessageDialog(null, "OS: " + System.getProperty("os.name")); DecimalFormatSymbols objDecimalFormat; objDecimalFormat = new DecimalFormatSymbols(); JOptionPane.showMessageDialog(null, "Decimal symbol: " + objDecimalFormat.getCurrencySymbol() + "\r\n" + "Decimal separator: " + objDecimalFormat.getDecimalSeparator() + "\r\n" + "Grouping seperator: " + objDecimalFormat.getGroupingSeparator() + "\r\n" + "Percentage: " + objDecimalFormat.getPercent());
While testing the same on MAC it will always shows US English irrespective of what is set in the preferences section. We have about 10 language files which needs to be used based on the Locale that is set on the client’s machine and also to use the currency symbol, number format and date format.
Any help will be much appreciated. Thanks