Unprefix recognized language

pull/177/head
M66B 5 years ago
parent 179ea5185c
commit cb3629b880

@ -3081,7 +3081,7 @@ public class FragmentCompose extends FragmentBase {
String subject = (ref.subject == null ? "" : ref.subject);
if ("reply".equals(action) || "reply_all".equals(action)) {
if (prefix_once)
for (String re : Helper.getStrings(context, R.string.title_subject_reply, ""))
for (String re : Helper.getStrings(context, ref.language, R.string.title_subject_reply, ""))
subject = unprefix(subject, re);
data.draft.subject = context.getString(R.string.title_subject_reply, subject);
@ -3098,7 +3098,7 @@ public class FragmentCompose extends FragmentBase {
}
} else if ("forward".equals(action)) {
if (prefix_once)
for (String fwd : Helper.getStrings(context, R.string.title_subject_forward, ""))
for (String fwd : Helper.getStrings(context, ref.language, R.string.title_subject_forward, ""))
subject = unprefix(subject, fwd);
data.draft.subject = context.getString(R.string.title_subject_forward, subject);
} else if ("editasnew".equals(action)) {

@ -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]);
}

Loading…
Cancel
Save