Android SharedPreferences Tutorial and Example

Localising Android apps with locale resources

Locale support lets an Android app present text, dates, numbers, and layouts in a language and region that suit the current user. A French speaker in Melbourne and an English speaker in Perth can receive relevant content without downloading a separate application. Locale handling also improves accessibility when users combine a translation with a regional preference.

Android resolves resources through qualifiers such as language, region, script, and variant. The active configuration exposes the selected locale, so screens can reload when the choice changes. Android 13’s per-app language controls provide a system entry for supported translations, while AndroidX lets the same behaviour cover older devices.

Australian localisation has several useful details. Australian English normally uses spellings such as “organise” and “realise,” while Sydney and Melbourne contain large Greek, Mandarin, Italian, and Arabic-speaking communities. Australian dollars are written as AUD or A$, and addresses use state names and postcodes. Because the country spans several time zones, clock time should not be inferred from the device locale.

A practical implementation needs more than translated strings. Developers should plan resource selection, locale-aware formatting, user-controlled switching, and testing on devices with different language and region settings. The following approach works from a simple starter project through to a production app.

Choose how users select a locale

Decide whether the system, AndroidX, or your own interface should own locale selection. The system picker feels familiar and supports Android 13’s per-app language screen. AndroidX offers a consistent custom picker on older releases and can store the preference automatically. An in-app selector provides branded guidance but requires more state and restoration work.

Locale control Best fit Main consideration
Android system picker Android 13 and newer Requires declared supported locales
AndroidX picker Broad device support Handles framework and legacy storage
Custom in-app picker Guided product experience You manage state, restoration, and feedback

Whichever path you choose, publish every selectable locale consistently and declare the same set in the platform configuration. A locale tag such as en-AU means Australian English, fr-FR means French for France, and ar covers Arabic without fixing a country. Keep the picker and metadata aligned so users cannot choose a language that has no resources.

Add regional and translated resources

Start with a default resource directory, then add qualified directories as translations arrive. Keep the fallback useful because Android may select it when a device language or region has no exact match.

res/values/strings.xml
res/values-en-rAU/strings.xml
res/values-fr/strings.xml
res/values-ar/strings.xml

Each file uses normal Android resource names. For example, checkout, cart_items, and delivery_status can point to different strings without changing Kotlin or Java code. A French file can also contain different plurals because one item and several items need different grammatical forms.

Language-only directories such as values-fr apply to every French region. Add values-fr-rCA when Canadian French needs distinct wording or formats, and use a script qualifier for languages written in several scripts. Translate meanings rather than preserving English word order, and avoid building sentences by joining translated fragments.

Declare and apply the chosen locale

Advertise the supported language tags so Android can display per-app language options. Create a locale configuration containing English for Australia, French, and Arabic.

<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
    <locale android:name="en-AU" />
    <locale android:name="fr" />
    <locale android:name="ar" />
</locale-config>

Reference it from the application with android:localeConfig="@xml/locales_config" and enable android:supportsRtl="true". On older Android versions, add AndroidX’s AppLocalesMetadataHolderService with autoStoreLocales enabled if the chosen locale must survive process restarts.

For an AppCompatActivity, a custom picker can change the locale through AppCompatDelegate. AndroidX delegates to the framework where per-app language support exists and provides compatible behaviour on earlier releases.

AppCompatDelegate.setApplicationLocales(
    LocaleListCompat.forLanguageTags(selectedTag)
)

Read AppCompatDelegate.getApplicationLocales() when you need the active choice for analytics, an API request, or a regional default. Do not assume that an empty list means French or any other language; it may mean the app is still using the system configuration.

Format regional content with the active locale

Resource translation solves words, not every cultural detail. Use DateFormat for dates, NumberFormat for decimal and currency values, and String.format with an explicit Locale for free-form text. A locale-aware currency formatter produces Australian dollar amounts correctly for the en-AU market.

Regional conventions also affect measurement, addresses, and names. Australia commonly presents dates with day before month, while other supported languages may use month first. Offer units in a familiar format and keep machine-readable values such as coordinates and ISO timestamps in a fixed representation.

Right-to-left content needs more than translated labels. Use start and end attributes, test Arabic layouts, and avoid assuming that a telephone number, address, or monetary value follows English ordering. Keep time-zone handling separate from locale selection: a French locale in Brisbane still uses Brisbane time.

Test the experience across devices and languages

Create a repeatable matrix covering every locale, Android version, display size, font scale, and navigation mode. Run instrumentation tests after switching locales because Android normally recreates the activity when its configuration changes. Include large fonts, TalkBack, and pseudo-localised text to reveal clipped labels and poor expansion.

Test the language settings that matter in Australia as well as the translated content. Check Australian English copy alongside French and Arabic, and use regions such as fr-CA when the same language changes vocabulary or date conventions. On a Windows development machine, supplementary guidance on desktop Android testing tools can provide another route for quick Android environment checks.

Watch for non-language failures after switching. A locale change should not reset navigation state, discard a draft, or change the selected unit unexpectedly. Persistence tests should cover process death and device restart, while screenshot tests can compare spacing, truncation, and alignment between locales.

Ship localised releases with confidence

Before publishing, align the manifest, locale picker, translated resources, and store listing. In the Australian Google Play market, identify Australian English where appropriate, present prices in Australian dollars, and make clear whether displayed prices include GST. Keep support instructions and release notes understandable in every language offered.

Localisation continues after launch. Track crashes and feedback by locale, review each translation update, and avoid removing a language without checking its regional resources. Native speakers are especially valuable for detecting unnatural tone, misleading labels, and culturally incorrect examples.

Use this release checklist to keep each build consistent:

  • Use BCP 47 language tags throughout resources, configuration, and analytics.
  • Provide a useful default plus explicit en-AU content when wording differs.
  • Supply plurals, placeholders, and gender-aware wording where a language requires them.
  • Format dates, numbers, currencies, and measurements with the active locale.
  • Offer a visible locale picker and preserve the user’s selection across restarts.
  • Test every translation on real devices, including RTL layouts, large fonts, and accessibility tools.

Locale-specific releases remain one application: the device or picker supplies the language preference, while the backend supplies explicit currency, time-zone, and market data. That separation prevents a regional display preference from silently changing a transaction’s value.