Seventeen languages in Googly Player, and the Android traps we fixed to ship them properly

Why our in-app language picker needed an App Bundle change, a process-wide locale call and proper plural resources before it could be trusted in Arabic, Urdu and fifteen other languages.

Binary Buddies · 5 min read · 0 views
An evening of listening above a city of many rooftopsA dusk skyline of domes, towers and spires under a rising moon, a string of coloured lanterns swaying overhead, and a phone glowing on a balcony ledge beside a pair of headphones, a mug and a potted plant.

Adding a language picker to an Android app looks like an afternoon's work: a list, a tap, a refresh. The trouble is that most of the ways it goes wrong produce no error at all. The picker shows Hindi or Arabic as selected and the app carries on rendering English. Nothing crashes and nothing appears in the logs, so nobody finds out until a user does.

The other failures are quieter still. A language applied only to the visible screens leaves the media notification and the dialogs in the old language. A count glued onto a label with string concatenation reads correctly in English and lands on the wrong side of the label in Arabic and Urdu. A single format string for a number cannot express the six plural forms Arabic needs, or the four that Russian needs.

We ran into every one of these building the language support in Googly Player, our app for videos, music and photos, which ships in seventeen languages. Here is how each one is handled, and what to check if you are shipping a picker of your own.

Key takeaways

  • The language picker is independent of the system language and is applied to the whole app process, so services, notifications and dialogs follow it, not just the screens.
  • With language splits on in an App Bundle, Play delivers only the system language's resources and the picker silently renders English. We disable the splits so every translation ships in the base APK.
  • Counts are formatted, never concatenated, because concatenation puts the number on the wrong side of the label in Arabic and Urdu.
  • Plurals go through plural resources: Arabic needs six forms for a number, Russian four.
  • On Android 13 and later the choice is handed to the platform and shows up in the system's per-app language setting.

Seventeen languages, chosen inside the app

Googly Player has a full in-app language picker that is entirely independent of the system language. A phone can stay in English while the player runs in Bengali, or the other way round, and nobody has to change a device-wide setting to get there. The seventeen 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 (ગુજરાતી)

Two of them, Arabic and Urdu, are written right to left, and the app has full RTL support for both. That pair, together with the plural rules of Arabic and Russian, drives most of the engineering below. A picker that only ever meets left-to-right languages with English-style plurals hides most of its bugs; these languages are where they surface.

17languages in the in-app picker
2right-to-left languages, Arabic and Urdu
6plural forms Arabic needs for a number
4plural forms Russian needs

Every language listed in its own script

Each entry in the picker leads with the language's endonym, its own name in its own script, as the primary label, with the English name underneath. Someone who reads Bengali is looking for বাংলা, not for a word in a language they may not read well. Someone helping them set the app up can still find Bengali on the line below. The same holds for हिन्दी, العربية, 日本語 and the rest of the list.

The list is searchable, and it opens with a Suggested section built from the device locale, so the most likely choice is at the top rather than somewhere among seventeen rows. For Arabic and Urdu the language names are correctly anchored in the picker: a right-to-left name sits where a right-to-left reader expects it, rather than being pushed to the left edge like an English label.

How the language picker labels each languageThe device locale feeds a Suggested section. Each language entry shows its own name in its own script first, with the English name beneath: हिन्दी over Hindi, العربية over Arabic, 日本語 over Japanese.Device localeSuggested sectionहिन्दीHindiالعربيةArabic日本語JapaneseOwn name first, English beneath
Each entry leads with the name a speaker of that language would look for, and the English name sits underneath as a fallback.

One setting for the whole process, not only the screens

The chosen language is applied through AppCompatDelegate.setApplicationLocales, which sets it for the whole app process. That matters for a media app in particular. Googly Player plays in the background through a foreground media-playback service and posts a media notification, and neither of those is an activity. A language switch that only reaches activities leaves the notification and the dialogs speaking the old language while the player itself has moved on.

Applied process-wide, the choice covers services, notifications and dialogs as well as every screen. On Android 13 and later we go a step further and hand the choice to the platform, so it also appears under Settings › Apps › Googly Player › Language. A user who changes the language there rather than inside the app gets the same result, and the system and the app agree on which language is in use.

Where the chosen language is appliedThe in-app language picker calls setApplicationLocales, which applies the language to activities, services, notifications and dialogs. On Android 13 and later the choice is also handed to the platform and appears in the system's per-app language setting.In-app language pickersetApplicationLocalesActivitiesServicesNotificationsDialogsAndroid 13 and laterPer-app Language in Settings
One call carries the language to every part of the app, and on Android 13 and later the system's own setting reflects it too.
A lantern-lit street of small shops at duskA row of shopfronts with striped awnings in different colours, warm doorways and lit upper windows, blank signs swaying from the awnings and evening mist drifting along the street.

The App Bundle setting that silently undoes the picker

App Bundles let Play split resources by language and deliver only what a device appears to need. For most apps that is a sensible saving. For an app with its own language picker it is a trap: Play would deliver only the resources for the system language, so choosing Arabic on a phone set to English would find no Arabic strings on the device. The picker would then silently render everything in English, with no crash and nothing in the logs to point at the cause.

We deliberately disable language splits in Googly Player's App Bundle, so every translation ships in the base APK. Once the app is installed, all seventeen languages are already on the device, and switching between them never depends on what Play decided to deliver at install time. It is a one-line configuration choice, and it is the difference between a picker that works and one that only appears to.

Language splits on versus offWith language splits on, Play delivers only the system language and the picker falls back to English with no crash and nothing logged. With splits disabled, all translations ship in the base APK and the picker shows the chosen language.Language splits onLanguage splits offTranslations split by languageOnly system language deliveredPicker falls back to EnglishNo crash, nothing loggedLanguage splits disabledAll translations in base APKPicker shows chosen language
The left path fails without any signal; the right path is the configuration Googly Player ships with.

Numbers that land on the right side of the label

Every count in Googly Player is formatted, never concatenated. The string is "Total Videos: %d", with the number as a placeholder inside the translation, not "Total Videos: " + n, with the number glued onto the end in code.

In English the two look identical, which is why the concatenated version survives so long in so many apps. In Arabic and Urdu, which read right to left, concatenation puts the number on the wrong side of the label, because the code fixes the order instead of the translation. With a format string, where the number sits is part of each translated string, so it lands where that language puts it.

Counts show up throughout the app, from library totals to search results grouped by type, such as Videos, Music and Photos, each with its own count. Treating every one of them as a format string, rather than fixing the obvious ones, is what keeps an Arabic or Urdu screen from looking half-translated.

Concatenated versus formatted countsA concatenated count, label plus n, puts the number on the wrong side in right-to-left Arabic and Urdu. A formatted count with a %d placeholder places the number correctly.ConcatenatedFormatted"Total Videos: " + nArabic and Urdu read RTLNumber on the wrong side"Total Videos: %d"Arabic and Urdu read RTLNumber in the right place
Same label, same language: only the version where the number lives inside the translation reads correctly right to left.

Plurals with as many forms as the language needs

A format string solves where the number goes. It does not solve what the words around it should be. Arabic needs six grammatical forms for a number and Russian needs four: the noun that follows changes with the count itself. Any approach that chooses between a singular and a plural in code, or that keeps one format string per count, is wrong for both languages, and the mistakes show up on exactly the screens people look at most, the ones that tell them how much is in their library.

Googly Player uses proper Android plural resources for every count that needs them. Each translation supplies every form its language requires, and the platform picks the right one for the number on screen. Combined with formatted counts, this is what lets a library total read like a sentence written in Russian or Arabic rather than an English template with the words swapped out.

What it runs on, and where to get it

Googly Player is an Android app with Material Design 3 throughout. The in-app picker and the process-wide language work the same way on every version the app runs on; what changes with the Android version is how far the choice reaches into the system.

Android 13 and later

The app and the system share the setting.

  • In-app picker with all seventeen languages
  • Choice handed to the platform
  • Also shown under Settings › Apps › Googly Player › Language

Earlier Android versions

The app manages the setting itself.

  • In-app picker with all seventeen languages
  • Applied process-wide through setApplicationLocales
  • Set and changed from inside the app

Nothing extra has to be downloaded to switch languages. Because language splits are disabled, every translation arrives in the base APK that Play delivers, so the full set is on the phone from the first launch. Choosing Arabic or Urdu turns on the app's right-to-left support, and none of it requires changing the phone's own language. Googly Player is distributed through Google Play.

Questions

Do I have to change my phone's language to use Googly Player in another language?

No. The in-app picker is entirely independent of the system language, so the phone can stay in one language while the player runs in any of the seventeen it supports.

Why does the picker show names like 日本語 instead of Japanese?

Each language is listed by its own name in its own script, because that is what a speaker of the language looks for. The English name is shown underneath, and the list is searchable with a Suggested section based on the device locale.

Will the playback notification switch language as well?

Yes. The language is applied to the whole app process through AppCompatDelegate.setApplicationLocales, which covers services, notifications and dialogs as well as the app's screens.

Does switching language download anything?

No. Language splits are disabled in the App Bundle, so every translation ships in the base APK and is already on the device once the app is installed.

Which languages read right to left?

Arabic and Urdu. Both have full RTL support, including correctly anchored language names in the picker and counts that are formatted rather than concatenated, so numbers land on the correct side of their labels.

  • #Android localization
  • #Android plural resources
  • #Arabic and Urdu
  • #Googly Player
  • #RTL support
  • #in-app language picker

Comments

Add a comment
Sign in with Google to join the conversation