1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-24 03:27:59 +01:00

Errors: language selection for error description

This commit is contained in:
Georg Lukas 2019-07-30 15:33:38 +02:00
parent 4ca2c7cc69
commit 093b576e0d

View file

@ -66,15 +66,23 @@ public class AbstractError {
* @return the descriptive text or null.
*/
public String getDescriptiveText() {
String defaultLocale = Locale.getDefault().getLanguage();
String descriptiveText = getDescriptiveText(defaultLocale);
if (descriptiveText == null) {
descriptiveText = getDescriptiveText("en");
if (descriptiveText == null) {
descriptiveText = getDescriptiveText("");
}
if (descriptiveTexts.isEmpty())
return null;
// attempt to obtain the text in the user's locale, the English text, or the "" default
Locale l = Locale.getDefault();
String[] tags = new String[] {
l.getLanguage() + "-" + l.getCountry() + "-" + l.getVariant(),
l.getLanguage() + "-" + l.getCountry(),
l.getLanguage(),
"en",
""
};
for (String tag : tags) {
String descriptiveText = getDescriptiveText(tag);
if (descriptiveText != null)
return descriptiveText;
}
return descriptiveText;
return descriptiveTexts.values().iterator().next();
}
/**