Building an In-App Language Picker for 17 Android Languages

An in-app language picker can fail silently: no crash, no log entry, just English everywhere. Here are the traps we designed around in Googly Player.

Binary Buddies · 5 min read · 1 view

Android will happily tell your app which language the user's phone is set to. That is rarely the language the user wants for a given app. Someone with a phone in English may want a media player in Hindi, and someone with a phone in Arabic may want French. If you build the language picker yourself, you take on a set of problems that a single strings file does not prepare you for.

Most of those problems fail quietly. A picker can render everything in English for a user who chose Japanese, with no crash and nothing in the logs. A label like 'Total Videos' can put its number on the wrong side in Arabic. A plural can read wrongly in Russian because the code assumed one singular form and one plural form.

Googly Player, our video, music and photo app for Android, ships a full in-app picker for 17 languages that is independent of the system language. Below is how we built it, and the specific traps we designed around.

17 languages, chosen independently of the system

The picker covers English, Hindi (हिन्दी), Spanish (Español), Arabic (العربية), French (Français), Bengali (বাংলা), Portuguese (Português), Russian (Русский), Urdu (اردو), Indonesian (Bahasa Indonesia), German (Deutsch), Japanese (日本語), Turkish (Türkçe), Vietnamese (Tiếng Việt), Korean (한국어), Italian (Italiano) and Gujarati (ગુજરાતી).

The choice is made inside the app and does not depend on the system language. Someone can keep their phone in one language and run Googly Player in another, and the picker is where they make that change. It is a full picker, not a short list of the most common options.

A picker people can actually read

A language list is only useful if someone can find their own language in it, even when the app is currently showing a language they cannot read. So each entry uses its endonym, its own name in its own script, as the primary label, with the English name underneath. A Gujarati speaker looks for ગુજરાતી, not for 'Gujarati'.

The list is searchable, and it has a 'Suggested' section at the top based on the device locale. With 17 entries in several scripts, those two features save scrolling. The suggestion is only a shortcut: the user can still pick anything on the list.

Right-to-left, including the picker itself

Arabic and Urdu get full RTL support throughout the app. That includes the language picker, where the language names are anchored correctly. This detail is easy to miss. If the picker itself mirrors wrongly, the people who most need it are the first to notice.

RTL also shapes how we write strings, which the next two sections cover. Layout mirroring is the visible half. The other half is making sure text and numbers are assembled in a way that survives reordering.

Applying the locale to the whole process

We apply the chosen language with AppCompatDelegate.setApplicationLocales. That call works at process level, so the language applies to services, notifications and dialogs as well as activities. This matters for a media player, because much of what the user sees is outside an activity. The playback notification is the obvious example.

On Android 13 and later, the choice is also handed to the platform. The result is that the language appears under Settings › Apps › Googly Player › Language, so the user can change it from system settings as well as from inside the app. Both routes lead to the same setting.

The App Bundle split that turns every language into English

This is the trap that does the most damage. With default App Bundle settings, Play delivers only the resources for the system language. An in-app picker then has nothing to switch to, and the app renders everything in English. It does not crash and it writes nothing to the logs, so you would only notice by running the app on a device whose system language differs from the one you chose.

We deliberately disable language splits in the App Bundle so that every translation ships in the base APK. The trade-off is a larger base APK. We accept that, because an independent in-app language choice cannot work if the resources are not on the device.

If you build your own picker, this is the first thing to check, and the check is quick: choose a language that differs from the device language and confirm the strings actually change.

Counts are formatted, never concatenated

We write counts as formatted resources, such as Total Videos: %d, and never as a string plus a number. Concatenation fixes the number's position relative to the label. In Arabic and Urdu the number ends up on the wrong side of the label.

A format string lets each translation decide where the number goes. The translator controls the placement, and the code does not need to know which language is active. It is a small rule, but it has to be applied everywhere a count appears, because a single concatenated string is enough to break the layout in two of the 17 languages.

Plurals need plural resources

A format string cannot express plural rules, and the languages in the picker show why. Arabic needs six grammatical forms for a number, and Russian needs four. A pattern of one singular and one plural string covers English, and fails for these.

We use proper Android plural resources, so each language declares the forms it needs and the platform picks the correct one for the number. Combined with formatted counts, this means a label such as a video or photo total reads correctly whichever of the 17 languages is selected.

What to check if you build the same thing

  • Call AppCompatDelegate.setApplicationLocales so the language covers services, notifications and dialogs, not just activities.
  • On Android 13+, expect the choice to appear in the system's per-app language settings, because the platform takes it over.
  • Disable language splits in the App Bundle so all translations ship in the base APK.
  • Use format strings for every count, and plural resources for every quantity.
  • Label each language by its endonym with the English name beneath, and anchor the names correctly for Arabic and Urdu.

Everything above is built into Googly Player's own language picker, and it applies to the video, music and photo sections alike. If you are weighing us for Android work that has to ship in many languages, these are the failure modes we have already designed around.

  • #Android localization
  • #Android plural resources
  • #Googly Player
  • #RTL Android
  • #in-app language picker

Comments

Add a comment
Sign in with Google to join the conversation