Is there any solution to display to the user a date using his locale settings but the words to be in a different language?
What I want is to display to a user that has set up en_US a date in german language (month names, weekdays for example).
Good question. It is possible if you first create an NSDateFormatter
with the user's locale (default), set its style, then store the current date format. After that, set the locale to the language you want to display and reset the date format:
NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelease];
[df setDateStyle:NSDateFormatterFullStyle];
NSString *usersDateFormat = [df dateFormat];
[df setLocale:[[[NSLocale alloc] initWithLocaleIdentifier(@"de_DE")] autorelease]];
[df setDateFormat:usersDateFormat];
NSString *dateString = [df stringFromDate:[NSDate date]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With