How to localize a time period (iOS / OSX)

Does anyone know a way to localize a time period (e.g. 2.5 days or 6 months)

It seems like the solution is to use the stringsdict file - but that poses me as a problem that should have been solved already?

thank

+4
source share
1 answer

This is what it does NSDateComponentsFormatter. Example from the docs:

NSDateComponentsFormatter* formatter = [[NSDateComponentsFormatter alloc] init];
formatter.unitsStyle = NSDateComponentsFormatterUnitsStyleFull;
formatter.includesApproximationPhrase = YES;
formatter.includesTimeRemainingPhrase = YES;
formatter.allowedUnits = NSCalendarUnitMinute;
// Use the configured formatter to generate the string.
NSString* outputString = [formatter stringFromTimeInterval:300.0];

gives "About 5 minutes left."

+3
source

All Articles