In-App Language Picker on Android: 17 Languages Done Right

Silent English fallbacks, numbers on the wrong side of Arabic labels, and plural forms a format string cannot express: what we learned localising an Android media app.

Binary Buddies · 5 min read · 2 views

You add a language picker to an Android app, translate the strings, and pick Hindi on a test device. The app comes up in English. There is no crash and nothing in the logs. The translations exist in your project, but they never reached the device. This failure is quiet, and it usually surfaces only after release.

The other failures are quieter still. A count concatenated onto a label puts the number on the wrong side in Arabic. A format string cannot express the plural rules of Russian. A picker that lists languages only by their English names is hard to use for someone who cannot read English. A language switch that changes activities but leaves notifications and dialogs in the old language looks half-finished.

Googly Player is our media app for videos, music and photos. It has a 17-language in-app picker that is independent of the system language. This article covers how we built it and which decisions mattered.

A picker that people can actually read

Each language is listed by its endonym, its own name in its own script, as the primary label. The English name sits underneath as a secondary line. Someone who reads only Gujarati finds ગુજરાતી without having to recognise the word 'Gujarati'.

The picker is searchable and has a 'Suggested' section built from the device locale. A phone set to Turkish shows Türkçe near the top before the user scrolls or types.

The 17 languages are:

  • 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)
  • Gujarati (ગુજરાતી)

The picker is a full in-app control, entirely independent of the system language. A user can run Android in one language and Googly Player in another.

Applying the choice process-wide

We apply the selected language through AppCompatDelegate.setApplicationLocales. That call covers the whole process, not just the activities. Services, notifications and dialogs follow the same locale. This matters for a media player because the playback notification is one of the most visible surfaces the app has, and it is not an activity.

On Android 13 and later, the choice is handed to the platform. The language then also appears under Settings › Apps › Googly Player › Language. The two places stay in agreement because the system owns the setting, and the app is not keeping a private copy of it.

Per-activity locale overrides are the usual alternative. They leave gaps: any component that is not an activity can come up in the wrong language. Using the process-wide call avoids that class of bug.

The App Bundle trap: language splits

This was the most expensive lesson, and it produces exactly the symptom described at the top of this article. When an app ships as an Android App Bundle, Play can split the install by language and deliver only the resources for the system language. For an app with an in-app picker that is wrong. A user whose phone is set to English picks Japanese, and the Japanese strings are not on the device.

The result is not a crash. The picker accepts the choice and everything renders in English. Nothing appears in the logs, so you can lose a lot of time looking for a bug in code that is working correctly.

We deliberately disable language splits in the App Bundle configuration. Every translation ships in the base APK. The cost is a somewhat larger base install. The benefit is that the picker does what it says. If your app lets users choose a language other than the system one, this setting is a requirement.

Right-to-left support for Arabic and Urdu

Arabic and Urdu get full RTL support. That includes the picker itself: language names there are correctly anchored, so the list does not look mirrored by accident or left-aligned against the reading direction.

Layout mirroring is only part of the work. Text assembled in code is the other part. If you build a label by joining a string to a number, such as "Total Videos: " + n, the number ends up on the wrong side of the label in Arabic and Urdu. The sentence is no longer in the order a reader expects.

For that reason we never concatenate counts. We format them through a resource string, "Total Videos: %d", so each translation decides where the number goes. It is a small rule, and it is easy to break in a late feature. A concatenation in one corner of the app is enough to produce a wrong-way label in two languages.

Plurals need plural resources

A format string can place a number, but it cannot say how a language changes its words around that number. Arabic needs six grammatical forms for a number. Russian needs four. English gets by with two, and code written with English in mind often assumes that is universal.

We use proper Android plural resources instead. Each language supplies the forms it needs, and the platform picks the right one for the count. The code that displays '12 videos' or '1 video' does not branch on the number itself. It asks for the plural for that quantity.

The alternative is an if-statement that picks between a singular and a plural string. That works in English and gives wrong grammar in Russian and Arabic. Of the 17 languages we support, those two alone make it a poor choice.

Testing that catches the silent failures

The failures above share a trait: none of them throws an error. A review of the code will not necessarily find them. They show up only when you look at the running app in the right configuration. These are the checks that follow from our own experience:

  • Install from a bundle build, not just a debug APK, with the system set to English and the app set to another language. This is the check that exposes disabled or enabled language splits.
  • Switch to Arabic or Urdu and look at counts, labels and the picker. A number on the wrong side of its label means a string was concatenated somewhere.
  • Look at the playback notification and a dialog, not just the main screens. They confirm the process-wide locale is being applied.
  • On Android 13 or later, open Settings › Apps › Googly Player › Language and confirm it matches the in-app choice.
  • Check counts in Russian and Arabic, where plural forms differ most from English.

The bundle check is the most important of these, because a debug install can hide the split problem entirely.

What you need to use this approach

The pieces are standard Android. The in-app locale call comes from AppCompat through AppCompatDelegate.setApplicationLocales. On Android 13 and later the platform takes over the setting and lists it in system Settings. On earlier versions the app applies it through the same AppCompat call.

You need to ship translations as ordinary Android string and plural resources, with language splits disabled in your App Bundle configuration so they all reach the device. You also need the discipline of formatting every count through a resource string and using plural resources wherever a count changes the wording.

For Googly Player, the result is 17 languages, with Arabic and Urdu fully right-to-left, selectable inside the app, and applied to services, notifications and dialogs as well as screens. If you are building a localised Android app and want this done correctly from the start, this is the checklist we would give you.

  • #Android localization
  • #Android plurals
  • #Googly Player
  • #in-app language picker

Comments

Add a comment
Sign in with Google to join the conversation