Locale-Sensitive Objective-C Method
Foundation NSDateFormatter
NSDateFormatter setDateFormat:
Internationalization (I18n) Method Overview
This method is used for fine grained tuning of date-time formats.
Click here
for additional Apple Developer Documentation details.
I18n Issues
Rather than utilize the System Defaults Database of locale formats,
this explicitly overrides the formatting. While whatever is provided may be
appropriate for English and a few other preset locales, this may not serve all locales in the
future.
Generally one prefers to set date style, set date template (see method dateFormatFromTemplate) which
is locale reactive,
or set format from a resource file.
Resolution:
- Consider going back to system locale-specific defaults
- Expose the formats in resource files to be determined by localization engineers
- Use date style so it is more template driven across locales (generally one prefers to set date
style)
- Set date template (see method
dateFormatFromTemplate ) which is locale reactive.
Also note that although setting a format string in principle specifies an exact format,
in practice it may nevertheless be overridden by a user's preferences (see Data Formatting Guide).
Generally one needs to pass in locale , encoding or language to
ensure that any culture-dependent conversion is done properly.
If you determine that the call is i18n-safe, you can use Globalyzer's
Ignore Comment functionality to ensure
that it isn't picked up in a subsequent scan.
For information about Objective-C Internationalization, click here.
|