mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 21:59:54 +01:00
Update the system configuration locale
This commit is contained in:
@@ -80,13 +80,25 @@ public class Localizer {
|
|||||||
if (locale.equals(currentLocale))
|
if (locale.equals(currentLocale))
|
||||||
return context;
|
return context;
|
||||||
Locale.setDefault(locale);
|
Locale.setDefault(locale);
|
||||||
if (SDK_INT >= 17) {
|
updateConfiguration(conf, locale);
|
||||||
conf.setLocale(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);
|
context.createConfigurationContext(conf);
|
||||||
} else
|
|
||||||
conf.locale = locale;
|
|
||||||
//noinspection deprecation
|
//noinspection deprecation
|
||||||
res.updateConfiguration(conf, res.getDisplayMetrics());
|
res.updateConfiguration(conf, res.getDisplayMetrics());
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateConfiguration(Configuration conf, Locale locale) {
|
||||||
|
if (SDK_INT >= 17) {
|
||||||
|
conf.setLocale(locale);
|
||||||
|
} else
|
||||||
|
conf.locale = locale;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user