Skip to content

Instantly share code, notes, and snippets.

@ushuz
Last active March 20, 2026 01:41
Show Gist options
  • Select an option

  • Save ushuz/4f8c2771b295330b23154acfc00795b3 to your computer and use it in GitHub Desktop.

Select an option

Save ushuz/4f8c2771b295330b23154acfc00795b3 to your computer and use it in GitHub Desktop.
Fix macOS global "Country" setting
# view gloabl prefs in json
# plutil -convert json -o - -- /Library/Preferences/.GlobalPreferences.plist | python -m json.tool
import CoreFoundation as cf
# get current Country
cf.CFPreferencesCopyValue('Country', cf.kCFPreferencesAnyApplication, cf.kCFPreferencesAnyUser, cf.kCFPreferencesAnyHost)
# set Country
cf.CFPreferencesSetValue('Country', 'TW', cf.kCFPreferencesAnyApplication, cf.kCFPreferencesAnyUser, cf.kCFPreferencesAnyHost)
# persist changes
cf.CFPreferencesSynchronize(cf.kCFPreferencesAnyApplication, cf.kCFPreferencesAnyUser, cf.kCFPreferencesAnyHost)
# it's a lot easier to use 'defaults' to change the global .plist
#
# credit: @ShallJaiden in comments
#
sudo defaults write /Library/Preferences/.GlobalPreferences.plist Country -string "TW"
@ushuz

ushuz commented Jul 16, 2020

Copy link
Copy Markdown
Author

Need brew unlink python first if install the brew version before

Or, you can always use /usr/bin/python

@ShallJaiden

Copy link
Copy Markdown

this doesn't work for me. I just simply run sudo defaults write /Library/Preferences/.GlobalPreferences.plist Country -string "TW"
that works for me

@ushuz

ushuz commented Sep 13, 2021

Copy link
Copy Markdown
Author

this doesn't work for me. I just simply run sudo defaults write /Library/Preferences/.GlobalPreferences.plist Country -string "TW"
that works for me

Thanks for sharing, that's far better. I'll incorporate it into the script for future visitors.

@robcholz

Copy link
Copy Markdown

Thank you. This has fixed the problem that bothers me for a long time!

@bit-happy

Copy link
Copy Markdown

thanks, works on my MBP 2021 M1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment