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.
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]
.
For the app title you have to look into Localizing Property List Values. In short: use InfoPlist.strings files in your localized directories.
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
To localize your application name:
Make a locale folder entitled
en.lproj
for English,de.lproj
for German,fr.lproj
for French, etc. inside your Xcode project folderIn each
*.lproj
folder, create a file calledInfoPlist.strings
through Xcode:a. Click on the
File
menu and selectNew File...
b. Select the
Other
group and click onStrings
c. Add the new strings file with the required name in the desired locale folder
In your Xcode project, navigate to the
InfoPlist.strings
item and open its disclosure triangleClick on
en
for English, and add the string:CFBundleDisplayName = "AppNameInEnglish";
For German, click on
de
and add the string:CFBundleDisplayName = "AppNameAufDeutsch";
And so forth...
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....
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.