Skip to content

SaschaZ/LocaleEx

Repository files navigation

LocaleEx

Android localization extension

LocaleEx provides functionality to define an exclusive Locale in your app without changing the Android system Locale.

Features:

  • applied Locale is stored persistent and is restored on app restart
  • to make sure the defined Locale is also set for your Applications Context and any or your Services Contexts the app is automatically restarted when a new Locale is set by the user
  • to fine tune LocaleEx for your needs nearly every action can be configured. see the ILocaleExPreferences interface and demo app for all available options and how they effect the Locale

Import:

  • root build.gradle:
    allprojects {
      repositories {
        ...
        maven { url "https://jitpack.io" }
      }
    }
  • app build.gradle:
    dependencies {
      implementation "com.github.SaschaZ:LocaleEx:1.0.5"
    }

To use LocaleEx you need to extend all of your Activitys from LocaleExActivity and your Application from LocaleExApplication. If you do not have a custom Application please add the following to your application tag in your Manifest.xml:

<application
    android:name="de.gapps.localeex.impl.LocaleExApplication"

Now you can use the LocaleEx.locale property to define your custom Locale:

LocaleEx.apply { context.locale = Locale("en", "EN") }

Be sure to apply any custom settings to LocaleExPreferences before setting your custom Locale.

If you do not want to extend your Activitys and Application from the LocaleEx ones you can also let them implement ILocaleEx by LocaleEx and copy the appropriate LocaleEx calls to your implementations.

Known issues:

  • All views that are created directly by Android and not by the app (permission request dialogs for example) still using the system locale.

About

Android localization extension

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages