|
|
|
@ -753,25 +753,39 @@ public class Helper {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static String[] getStrings(Context context, int resid, Object... formatArgs) {
|
|
|
|
|
List<String> result = new ArrayList<>();
|
|
|
|
|
return getStrings(context, null, resid, formatArgs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static String[] getStrings(Context context, String language, int resid, Object... formatArgs) {
|
|
|
|
|
List<Locale> locales = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
if (language != null)
|
|
|
|
|
locales.add(new Locale(language));
|
|
|
|
|
|
|
|
|
|
Configuration configuration = new Configuration(context.getResources().getConfiguration());
|
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
|
|
|
|
result.add(context.getString(resid, formatArgs));
|
|
|
|
|
if (!Locale.getDefault().getLanguage().equals("en")) {
|
|
|
|
|
configuration.setLocale(new Locale("en"));
|
|
|
|
|
Resources res = context.createConfigurationContext(configuration).getResources();
|
|
|
|
|
result.add(res.getString(resid, formatArgs));
|
|
|
|
|
}
|
|
|
|
|
Locale l = Locale.getDefault();
|
|
|
|
|
if (!l.getLanguage().equals(language))
|
|
|
|
|
locales.add(l);
|
|
|
|
|
if (!"en".equals(language) && !"en".equals(l.getLanguage()))
|
|
|
|
|
locales.add(new Locale("en"));
|
|
|
|
|
} else {
|
|
|
|
|
LocaleList ll = context.getResources().getConfiguration().getLocales();
|
|
|
|
|
for (int i = 0; i < ll.size(); i++) {
|
|
|
|
|
configuration.setLocale(ll.get(i));
|
|
|
|
|
Resources res = context.createConfigurationContext(configuration).getResources();
|
|
|
|
|
result.add(res.getString(resid, formatArgs));
|
|
|
|
|
Locale l = ll.get(i);
|
|
|
|
|
if (!l.getLanguage().equals(language))
|
|
|
|
|
locales.add(l);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<String> result = new ArrayList<>();
|
|
|
|
|
Configuration configuration = new Configuration(context.getResources().getConfiguration());
|
|
|
|
|
for (Locale locale : locales) {
|
|
|
|
|
configuration.setLocale(locale);
|
|
|
|
|
Resources res = context.createConfigurationContext(configuration).getResources();
|
|
|
|
|
String text = res.getString(resid, formatArgs);
|
|
|
|
|
result.add(text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result.toArray(new String[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|