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 yourApplication
sContext
and any or yourService
sContext
s the app is automatically restarted when a newLocale
is set by the user - to fine tune
LocaleEx
for your needs nearly every action can be configured. see theILocaleExPreferences
interface and demo app for all available options and how they effect theLocale
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 Activity
s 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 Activity
s 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.