Home > Articles > Home & Office Computing > Mac OS X

  • Print
  • + Share This
From the author of

Looking up the localized version of something can be relatively expensive, so it's quite tempting to cache the result. The best advice is to never do this. You only ever need to localize things that are displayed to the user, and most of the time the cost of drawing something on the screen is a lot more than the cost of getting the localized version.

Occasionally, you may discover that the localization is a bottleneck. In this case, you can try caching localized resources. This can be problematic if the user then switches locales.

Most things will be updated automatically, but there are two exceptions. The first is anything that you've cached, and the second is nib files. Newly instantiated nib files will be selected from the new locale, but existing ones will come from the old locale. This can be confusing for the user.

You can spot when the locale has changed by registering to observe the NSCurrentLocaleDidChangeNotification notification from the NSLocale class.

  • + Share This
  • 🔖 Save To Your Account