mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-24 23:32:05 +01:00
Merge pull request #330 from ge0rg/errlang
Errors: language selection for error description
This commit is contained in:
commit
65b6a7bfa2
1 changed files with 16 additions and 8 deletions
|
@ -66,16 +66,24 @@ 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 descriptiveTexts.values().iterator().next();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the descriptive test of this SASLFailure.
|
||||
|
|
Loading…
Reference in a new issue