Localized Resources

If a bundle is to be used in more than one part of the world, its resources may need to be customized, or localized, for language, country, or cultural region. An application may need to have separate Japanese, English, French, Hindu, and Swedish versions of the character strings that label menu commands. An application may also need to accommodate regional language variation--British and American English, for example.

Bundle Services solves this problem by grouping resources together into folders named for their region and language with the extension .lproj . Region specific resource folders should take their names from the ISO 3166 standard for country codes, and the ISO 639 standard for language codes. You would place resources specific to the dialect of French spoken in France in a folder named fr_FR.lproj whereas you would place resources specific to Canadian French in a folder named fr_CA.lproj . Localized resources that need not be region specific should be placed in folders named simply for the language, such as English.lproj or Japanese.lproj . These localized resource directories are then placed in a folder named Resources . Non-localized (global) resources are also kept in the Resources folder, but appear at the top level alongside the localized resource directories. See the section Anatomy of a Bundle for an example of a complex bundle's file system layout.

The user determines which set of localized resources are actually used by the bundle at runtime. CFBundle objects rely on the language preferences set by the user in the Preferences application. Preferences lets users create an ordered list of available regions so that the most preferred region is first, the second most preferred region is next, and so on. When a CFBundle is asked for a resource file, it returns the URL of the resource that best matches the user's region preferences. See the section Search Algorithm for details on the exact process CFBundle uses to locate a resource.


© 2000 Apple Computer, Inc. (Last Updated 30 June 2000)