Skip to content
Snippets Groups Projects
Commit 80ec29b7 authored by Julian Dehm's avatar Julian Dehm Committed by jd
Browse files

Update the system configuration locale

parent f45d00e2
No related branches found
No related tags found
No related merge requests found
......@@ -80,13 +80,25 @@ public class Localizer {
if (locale.equals(currentLocale))
return context;
Locale.setDefault(locale);
if (SDK_INT >= 17) {
conf.setLocale(locale);
updateConfiguration(conf, locale);
Configuration systemConfiguration =
Resources.getSystem().getConfiguration();
updateConfiguration(systemConfiguration, locale);
// DateUtils uses the system resources, so we need to update them too.
// Apparently updateConfiguration is not deprecated here but is below.
Resources.getSystem().updateConfiguration(systemConfiguration,
Resources.getSystem().getDisplayMetrics());
if (SDK_INT >= 17)
context.createConfigurationContext(conf);
} else
conf.locale = locale;
//noinspection deprecation
res.updateConfiguration(conf, res.getDisplayMetrics());
return context;
}
private void updateConfiguration(Configuration conf, Locale locale) {
if (SDK_INT >= 17) {
conf.setLocale(locale);
} else
conf.locale = locale;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment