Agent Wranglers

LOC-37Recommended

Support the system's per-app language setting

Declare every language the app ships so iOS and Android list it in the system's per-app language setting. An in-app language picker opens that setting or uses the platform API, instead of a separate home-made switch.

How to do it

Android 13 added a system setting where people choose a language for each app. Declare the languages with generateLocaleConfig in the Android Gradle plugin, or a locale_config.xml named in the manifest. Set the language from inside the app with AppCompatDelegate.setApplicationLocales. On iOS, the setting appears for apps with several localizations when the person has more than one preferred language. Add UIPrefersShowingLanguageSettings to show it always. Apple advises opening Settings instead of building your own switch. Save the choice on the account too, as Store language and time zone as two separate settings says, so email follows it.

Examples

Kotlin example

// build.gradle.kts: android { androidResources { generateLocaleConfig = true } }
// res/resources.properties: unqualifiedResLocale=en-US
AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags("sv-SE"))

Plain text example

// Info.plist: UIPrefersShowingLanguageSettings = YES
if let settings = URL(string: UIApplication.openSettingsURLString) {
    UIApplication.shared.open(settings)
}

How to check

On a test device with Android 13 or later, the app's system settings page lists every shipped language. Choosing one restarts the app in it. On iOS, the app's Settings page shows a Language row that lists every shipped language.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/localization/apps-and-command-line-tools/per-app-language">Agent Wranglers localization playbook</a>. In code you write, add a comment next to it with the same link.