Decimal Seperator in Mac OS X

From Exterior Memory
Jump to: navigation, search
This article was written in January 2007, and last updated in June 2010. This issue was fixed in Mac OS 10.6. The content is no longer updated, and may be outdated.

In Mac OS 10.4 (Tiger) and Mac OS 10.5 (Leopard), there is no easy way to set the decimal separator (the decimal point) to a custom format (10 000.00) rather than European (10.000,00) or US format (10,000.00).

This worked fine in Mac OS 10.3, and it took until Mac OS 10.6 until this was fixed. This pages describes the (unsuccessful) attempts I made to fix it.

In Mac OS 10.3, this format was customizable in the "Internationalization" preference pane, on the "Formats" tab. Even in 10.4 and 10.5, you can select a preset from a long list, and further customize the date format and the time format. However, if you want a specific language. Say, Dutch or German there is no way you can have anything but "10.000,00" as the number format. If you want a dot as a decimal point to allow easy compatibility in Excel or FileMaker Pro, you are screwed.

Unfortunately, there is no short solution. I gave up, and now use a customized variant of "United States (Computer)". This bug was finally fixed in Mac OS 10.6.


Contents

Solution 1: Use the 10.3 Preference Pane

Of course, the sad thing is that in 10.3 you could change it, but some ass-head at Apple screwed up, and we now face wishes, to revert to the 10.3 preference pane. Unfortunately, Apple is ignoring it's customers for about two year now.

The solution listed by Mac OS X hints 10.4: Restore custom international number formats is to use the 10.3 (Panther) preference pane:

  1. Find a copy of the Localization.prefPane on a Panther system.
  2. Copy this file (actually a bunch of files in a bundle) to ~/Library/PreferencePanes/ on your 10.4 system. From then on, if you open the system preferences, you will simply get the (much better) 10.3 preference pane, which simply allows you to change the number format and the decimal point.

This solution only works for the PowerPC. It does not work for 10.4. Also, I found some problems with the "Input Menu" tab, also part of the Internationalization preference pane. You can get around this by only replacing the "Formats" tab, as described on the Mac OS X hints website. Still, this is probably not the best solution in the long run.

Solution 2: Tweak an existing locale

Perhaps the most future compatible solution is to tweak an existing locale. For example, I tweaked "United Stated (Computer)" as follows:

% defaults read .GlobalPreferences AppleICUDateFormatStrings
{
   1 = "d-M-yyyy";
   2 = "d MMM yyyy";
   3 = "d MMMM yyyy";
   4 = "EEEE d MMMM yyyy";
}

% defaults read .GlobalPreferences AppleICUTimeFormatStrings
{
   1 = "H:mm";
   2 = "H:mm:ss";
   3 = "H:mm:ss z";
   4 = "H:mm:ss v";
}

% defaults read com.apple.systempreferences AppleIntlCustomFormat
{
   AppleIntlCustomICUDictionary =     {
       AppleICUDateFormatStrings =         {
           1 = "d-M-yyyy";
           2 = "d MMM yyyy";
           3 = "d MMMM yyyy";
           4 = "EEEE d MMMM yyyy";
       };
       AppleICUTimeFormatStrings =         {
           1 = "H:mm";
           2 = "H:mm:ss";
           3 = "H:mm:ss z";
           4 = "H:mm:ss v";
       };
   };
   AppleIntlCustomLocale = "en_US_POSIX@currency=EUR";
}

Solution 3: Create a custom locale

In the International preference pane has many preset to choose from. Obviously, it reads the information from these preset from a file. If we change that file, we're there, right?

Well, it is possible, but not recommended.

For example, I can change the settings for Dutch. To do so, I have to change the settings in one of these files, depending on the setting of your current system language:

  • /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/Dutch.lproj/Localized.rsrc
  • /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/English.lproj/Localized.rsrc
  • /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/French.lproj/Localized.rsrc
  • /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/Italian.lproj/Localized.rsrc
  • /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/Japanese.lproj/Localized.rsrc
  • /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/Spanish.lproj/Localized.rsrc
  • /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/da.lproj/Localized.rsrc
  • /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/fi.lproj/Localized.rsrc
  • /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/ko.lproj/Localized.rsrc
  • /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/no.lproj/Localized.rsrc
  • /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/pt.lproj/Localized.rsrc
  • /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/sv.lproj/Localized.rsrc
  • /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/zh_CN.lproj/Localized.rsrc
  • /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/zh_TW.lproj/Localized.rsrc

To be exact, you must change one of the itl0 resources in the resource fork. One application to change the resource fork is Resorcerer, but resource forks are really an old (Mac OS Classic) format (note: I really love them, I regret they disappeared in Mac OS X, but they are old). Also, you have to keep changing this for each update of Mac OS X, since the preference pane seems to refer back to this file. It's a messy situation, and I really discourage you from changing anything in the /System/Library directory.

Solution 4: Manually change the settings in the preference files

OS-X 10.5 (Leopard) note:
.GlobalPreferences seems to override/replace (and delete) in com.apple.systempreferences and com.apple.HIToolbox


The short solution is:

  1. Open a terminal, and type (for dot as decimal separator and comma as thousand separator (e.g. 3,102.45€):
defaults write .GlobalPreferences AppleICUNumberSymbols -dict 0 '.' 1 ',' 10 '.' 8 '€'
defaults write .GlobalPreferences AppleICUNumberFormatStrings -dict-add 2 '#,##0.00¤;-#,##0.00¤'
defaults write com.apple.HIToolbox AppleDecimalSeparator  -dict smRoman '.'
defaults write com.apple.HIToolbox AppleThousandSeparator -dict smRoman ','
defaults write com.apple.systempreferences AppleIntlCustomFormat -dict-add AppleDecimalSeparator  '.'
defaults write com.apple.systempreferences AppleIntlCustomFormat -dict-add AppleThousandSeparator ','

That's it! You're done. Restart Excel, FileMaker Pro, and continue working. There is no need to log out or reboot.

In case you want the whole juicy story, read on.

Other example. For dot as decimal separator and space as thousands separator (e.g. €3 102.45), type:

  1. Open a terminal, and type:
defaults write .GlobalPreferences AppleICUNumberSymbols -dict 0 '.' 1 ' ' 10 '.' 8 '€'
defaults write .GlobalPreferences AppleICUNumberFormatStrings -dict-add 2 '¤# ##0.00;¤-# ##0.00'
defaults write com.apple.HIToolbox AppleDecimalSeparator  -dict smRoman '.'
defaults write com.apple.HIToolbox AppleThousandSeparator -dict smRoman ' '
defaults write com.apple.systempreferences AppleIntlCustomFormat -dict-add AppleDecimalSeparator  '.'
defaults write com.apple.systempreferences AppleIntlCustomFormat -dict-add AppleThousandSeparator ' '

The best solution is to find which preference files are in use by the Localization preference pane. These files could be determined using the ktrace tool:

  • /Library/Preferences/.GlobalPreferences.plist
  • /Users/freek/Library/Preferences/.GlobalPreferences.plist
  • /Users/freek/Library/Preferences/com.apple.HIToolbox.plist
  • /Users/freek/Library/Preferences/com.apple.systempreferences.plist

There is actually an easy way to find out what's in these files:

defaults read com.apple.systempreferences
defaults read com.apple.HIToolbox
defaults read .GlobalPreferences
defaults read /Library/Preferences/.GlobalPreferences

Regrettably, now of my files contained any "Decimal Separator" preference. So apparently I have not set this parameter, and my system is using the default value. Not really a surprise, since that is actually what I'm trying to change.

Fortunately, there are tricks to determine the correct name :

defaults write .GlobalPreferences NSDecimalSeparator    '.'
defaults write .GlobalPreferences NSThousandSeparator   ','
defaults write .GlobalPreferences NSGroupingSeparator   ','
  • The Mac OS X hints hint 10.4: Restore custom international number formats says the parameters are called AppleICUNumberFormatStrings and AppleICUNumberSymbols and should go in the (hidden) .GlobalPreferences file. He found out by changing the preferences using the 10.3 preference pane, and see what was changed in the file: clever! In fact, using that trick, it appears that the 10.3 preference pane also changes the AppleDecimalSeparator and AppleThousandSeparator in the com.apple.HIToolbox
defaults write .GlobalPreferences AppleICUNumberSymbols -dict 0 '.' 1 ',' 10 '.' 8 '€'
defaults write .GlobalPreferences AppleICUNumberFormatStrings -dict-add 2 '#,##0.00¤;-#,##0.00¤'
defaults write com.apple.HIToolbox AppleDecimalSeparator  -dict smRoman '.'
defaults write com.apple.HIToolbox AppleThousandSeparator -dict smRoman ','
# if you have problems with the Unicode EURO sign (€) and monitary symbol (¤):
defaults write .GlobalPreferences AppleICUNumberSymbols -dict 0 '.' 1 ',' 10 '.' 8 '\U20ac'
defaults write .GlobalPreferences AppleICUNumberFormatStrings -dict-add 2 '#,##0.00\U00a4;-#,##0.00\U00a4'
defaults write com.apple.HIToolbox AppleDecimalSeparator  -dict smRoman '.'
defaults write com.apple.HIToolbox AppleThousandSeparator -dict smRoman ','
  • A Decimal Point discussion on the AppleScript mailing list mentioned the keys AppleDecimalSeparator and AppleThousandSeparator as keys within the AppleIntlCustomFormat dictionary within the com.apple.systempreferences plist.
defaults write com.apple.systempreferences AppleIntlCustomFormat -dict-add AppleDecimalSeparator  '.'
defaults write com.apple.systempreferences AppleIntlCustomFormat -dict-add AppleThousandSeparator ','
  • A few people note that you can set the local from en_GB (English as Language and Great Brittain as Country) or nl_NL (Dutch as Language and Netherlands as Country) to en_NL (English as Language and Netherlands as Country). Well, this so-called "locale" variable is defined in AppleLocale in .GlobalPreferences, as well as in AppleIntlCustomLocale in the AppleIntlCustomFormat dictionary in com.apple.systempreferences, so you can change it there. Personally, I would not recommend this solution for two reasons. First, it changes so much more than just your decimal separator, and secondly, if you set your local to a variable undefined in the /usr/share/locale/ directory, I think this may lead to undefined behaviour. In short, it does more harm than good.

Our options

In short, we have a lot of options!

# Format as suggestion on rixstep.com
defaults write .GlobalPreferences NSDecimalSeparator        '.'
defaults write .GlobalPreferences NSThousandSeparator       ','
defaults write .GlobalPreferences NSGroupingSeparator.      ','

# Format as written by 10.3 system preferences (1)
defaults write .GlobalPreferences AppleICUNumberSymbols -dict 0 '.' 1 ',' 10 '.' 8 '€'

# Format as written by 10.3 system preferences (2)
defaults write .GlobalPreferences AppleICUNumberFormatStrings -dict-add 2 '#,##0.00¤;-#,##0.00¤'

# Format as written by 10.3 system preferences (3)
defaults write com.apple.HIToolbox AppleDecimalSeparator  -dict smRoman '.'
defaults write com.apple.HIToolbox AppleThousandSeparator -dict smRoman ','

# Format as suggestion on AppleScript mailing list
defaults write com.apple.systempreferences AppleIntlCustomFormat -dict-add AppleDecimalSeparator  '.'
defaults write com.apple.systempreferences AppleIntlCustomFormat -dict-add AppleThousandSeparator ','

# For fun, we throw in some other optiosn too (I ignore the thousands separator for briefness)
defaults write .GlobalPreferences AppleDecimalSeparator     '.'
defaults write .GlobalPreferences NSLocaleDecimalSeparator  '.'
defaults write com.apple.HIToolbox NSDecimalSeparator        '.'
defaults write com.apple.HIToolbox NSLocaleDecimalSeparator  '.'
defaults write com.apple.systempreferences AppleDecimalSeparator     '.'
defaults write com.apple.systempreferences NSDecimalSeparator        '.'
defaults write com.apple.systempreferences NSLocaleDecimalSeparator  '.'

Now, let's see how the application respond to the addition of one or more of the above preferences.

Application Tests

Script Editor (AppleScript)

Open the Script Editor, and run this small AppleScript:

display dialog item 2 of ((1/2) as string)

Unfortunately, I could not determine what makes the difference between dot and comma as decimal separator. On my Intel laptop, I always get a dot (.).

Calculator

Apple's Calculator, as found in /Applications/Calculator.app

Here, the AppleICUNumberSymbols key in the .GlobalPreferences clearly determines if a dot or comma is used to enter and display decimals separators:

defaults write .GlobalPreferences AppleICUNumberSymbols -dict 0 '.' 1 ',' 10 '.' 8 '€'

Microsoft Excel (Office 2004 version)

Unfortunately, I could not determine what makes the difference between dot and comma as decimal separator. On my Intel laptop, I always get a dot (.).


On my PowerPC, the distinction was very clear when using the 10.3 preference pane, but changing the value manually using defaults did not seem to have any effect. Perhaps I need to log out and log in first. Otherwise, I need to run ktrace and check a bit more (perhaps the 10.3 prefpane did write to yet other locations.

Bug Report

I actually reported the following bug to Apple on May 9, 2005:

Summary

Since Mac OS 10.4 (Tiger), there is no easy way to set the decimal separator. (the decimal point)

Goal

Obtain a system configuration, such that for dates, the names are set in Dutch (e.g. "januari" for the month "January", but the decimal separator is a dot instead of a comma (e.g. 3.1415 instead of 3,1415). This goal doesn't seem reachable.

Steps to Reproduce

  1. Open System Preference, and go to the International Preference Pane.
  2. Click the "Format" tab.
  3. Observer that there is no "Customize..." button to set the Numbers format
  4. Get frustrated
  5. Have a brainwave (thinking it should be possible to set the "Region" to USA, and then just customize the Date and the Time format to Dutch).
  6. Set the Region popup menu to "United States"
  7. Customize the Date for Long format to "5" "January" "2005".
  8. Observe that the Long date now says "5 January 2005", while I wanted it to say "5 januari 2005".

Expected results

I expected that the goal, as described above would be reachable somehow.

Actual results

I got frustrated. Till the present day I still have not discovered a way to reach my goal, and use a Dutch region setting, with only the decimal separator changed from comma to dot.

Notes

I have set my main language to English rather then Dutch, but this setting doesn't seem to have any effect.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox