Re: Localising paths
Re: Localising paths
- Subject: Re: Localising paths
- From: Chris Parker <email@hidden>
- Date: Wed, 18 Jun 2003 10:48:01 -0700
Hi Dale,
On Wednesday, June 18, 2003, at 2:33 AM, Dale Gillard wrote:
I'm confused about the use of NSSearchPathForDirectoriesInDomains()
and localising paths, and would appreciate your guidance.
NSSearchPathForDirectoriesInDomains() returns 0 or more paths found in
a specified directory. In my case, I need to access a folder 3 levels
deep within the user's Documents directory. Even though hard-coding
file paths is a Bad Thing, it seems in this case that I must hard code
the path from the user's Document directory to this folder so that I
can locate it.
If that is the case, my question relates to localising this hard coded
path. I understand that Mac OS X uses English named file paths and
displays the localised name of the path to the user. Does this mean
that I can hard code the above path in English, as in the following
snippet, and it will just work on a French user's system?
This is correct. The filesystem itself is laid out in English; only the
presentation to the user through the Finder or open & save dialogs is
localized. Constructing the path you're working with in English is the
correct thing to do.
If you want to display localized path components for a given path,
you'll likely be interested in NSFileManager's
-componentsToDisplayForPath: routine. This returns an NSArray of the
components in the user's current localization. It's worth noting here
that the array you get back -cannot- be recombined to produce a valid
path.
You should not localize your hardcoded path at all.
.chris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.