Date localization on supported languages

Hi,

We developed an application and gave support to some languages, if the user preferences don't contain any of them, it use a fallback base language instead.


This feature works for all strings, however we can not achive it for date localizations, they are translated in wichever the language of the phone preferences is. Obtaining all the application in a concrete language and the dates in another.


Is there a way to only translate the Date and Numbers in the supported languages and use the fallback language instead as we do with the rest of the strings?


Thank you very much


Eloi Gabaldon

Replies

Don't confuse regional settings for dates and currencies with language localizations.


See: https://developer.apple.com/library/ios/documentation/MacOSX/Conceptual/BPInternational/SpecifyingPreferences/SpecifyingPreferences.html

Is there a way to only translate the Date and Numbers in the supported languages and use the fallback language instead as we do with the rest of the strings?

Can you post a specific example of your two scenarios (supported and fallback)? I’d like to see what results your getting and what results you’d like to get in each case.

It’s likely that there’s some way to solve this problem but it’s hard to be sure without knowing more details.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

The problem is that the dates are translated in all languages despite the supported languages are only 2.


For example:

We have English as fallback language and Spanish as suported. If the system preferences are in any of these languages as principal language, everything works correctly.


However if the first language is another one (e.g French) all the app strings are shown in english as it is the fallback language but the dates are still translated in French.


What I mean for transkations is that we show the name of the month and the name of the day. What we obtain in the french example is an english application with all the menu and informstion in english with dates such as:

samedi 30 juillet 2016.

If spanish is at the second prefered language and french at the first, same problem. All app is in spanish but the dates in french.

For printing the dates we use the object NSDate and a NSDateFormatter to formate it to string. With:

let dateFormatter=NSDateFormatter()

dateFormatter.dateFormat="EEEE"// the day name e.g Monday

let string= dateFormater.stringFromDate(date)

The problem is that it always uses the first language on the general seetings instead of the 1st supported language or the fallback intead.

Thank you very much. If you need more specific configuration let me know.

I runed into an idea that worked.


1- In my supported languages files (Localizable.strings) I introduced a new string named "LOCALE" with the value "en" or "es" depending on each language.


2. before using the dateFormatter.striringFromDate(date) i used the LOCALE string to generate a locale object depending on the value.

let locale = NSLocale.init(localeIdentifier: NSLocalizedString("LOCALE", comment: "the locale of the dates"))

let dateFormatter = NSDateFormatter()

dateFormatter.dateFormat = "EEEE"

dateFormatter.locale=locale

let dayOfWeekString = dateFormatter.stringFromDate(self)


This worked, as i force the locale to be always the one specified in each Localized.strings file.


Thank you very much and let me know if there is another way to obtain the same result

Thanks for posting a specific example but…

The problem is that the dates are translated in all languages despite the supported languages are only 2.

this description only talks about the user’s language setting (Settings > General > Language & Region > iPhone Language). I don’t see any discussion of the user’s region settings (Settings > General > Language & Region > Region Formats). It’s hard to comment on your specific example without knowing how the region settings were set.

It’s seems like you’re trying to tightly bind locale to language. This is not a good idea. There are users who split these settings and, if your app binds them tightly, such users will be grumpy.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"