hennes hennes - 1 year ago 55
iOS Question

How to find iOS locale hierarchy

The iOS system automatically picks the most suitable available localization for an app. For instance, when the user's locale is

but the app only offers
, that'll act as a fallback (as explained here).

My question is: Is it possible to look up these hierarchies somewhere?

The reasoning behind this question is that, for instance, I may have translations in
, ... that are almost identical and instead of including separate string files for all of them, I'd like to just provide them for one common fallback locale. I know that I could simply use
in this exemplary case but it might not be that obvious in other scenarios.

Answer Source

Answering myself here:

    from: ["es", "es-419", "es-AR", "es-CL", "es-CO", "es-MX", "es-PE"],
    forPreferences: ["es-PE"])

returns ["es-PE", "es-419", "es"] which means Peruvian Spanish fill fall back to es-419 and es in order.