tags:

views:

676

answers:

6

I know how to localize strings for iPhone app (via the use of NSLocalizedString and Localizable.strings) How can I do the same for date time display? Right now I am using NSDateFormatter for date/time.

A: 

You probably want to look at NSLocale ... check the Locales Programming Guide. Getting your date formatters with constants from NSDateFormatter.h like

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];

should do the right thing with respect to the locale set by the user in their system settings.

You can check a formatter's current locale with [dateFormatter locale].

Ryan McCuaig
A: 

For the app title you have to look into Localizing Property List Values. In short: use InfoPlist.strings files in your localized directories.

Nikolai Ruhe
A: 
I had to localize hours and display hours regarding user pref (military time, 24H)
Here is my code :

NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setLocale: [NSLocale currentLocale]];
[dateFormatter setDateStyle:kCFDateFormatterNoStyle];
[dateFormatter setTimeStyle:kCFDateFormatterShortStyle];

NSLog([dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:currentSong.timestamp]]);

Hope this helps

Thierry

thierryb
A: 

To localize your application name:

  1. Make a locale folder entitled en.lproj for English, de.lproj for German, fr.lproj for French, etc. inside your Xcode project folder

  2. In each *.lproj folder, create a file called InfoPlist.strings through Xcode:

    a. Click on the File menu and select New File...

    b. Select the Other group and click on Strings

    c. Add the new strings file with the required name in the desired locale folder

  3. In your Xcode project, navigate to the InfoPlist.strings item and open its disclosure triangle

  4. Click on en for English, and add the string:

    CFBundleDisplayName = "AppNameInEnglish";

    For German, click on de and add the string:

    CFBundleDisplayName = "AppNameAufDeutsch";

    And so forth...

Alex Reynolds
A: 

Hi, Is there any way, to set language of the application, irrrespective of the current language setting of the device.

For example, i want my app to display all text in French, without changing the language settings of the device. the device will continue displaying data for other apps, in say, English.

Pls. reply as soon as possible....

Pravara
A: 

Select the "appname"-Info.plist, command-I and in the window you select the "Make File Localizable". Go back into the General tab, and add localized settings with the "Add localization" button.

Jonny