Android localization extension
LocaleEx provides functionality to define an exclusive Locale in your app without changing the Android system Locale.
Features:
- applied
Localeis stored persistent and is restored on app restart - to make sure the defined
Localeis also set for yourApplicationsContextand any or yourServicesContexts the app is automatically restarted when a newLocaleis set by the user - to fine tune
LocaleExfor your needs nearly every action can be configured. see theILocaleExPreferencesinterface 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 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.