Fixed NullPointerException case on 'Browser' lang selection

Occurred when English was the only active language, then making the
ConfigBasic.html page unusable until manually modifying the
locale.language setting.
This commit is contained in:
luccioman 2017-10-02 09:36:13 +02:00
parent ae1c675c85
commit 6b11bf3a12

View File

@ -326,16 +326,23 @@ public class Translator {
* @return list of language-codes of available/active translations
*/
public static List<String> activeTranslations() {
Switchboard sb = Switchboard.getSwitchboard();
File localePath;
if (sb != null)
final Switchboard sb = Switchboard.getSwitchboard();
final File localePath;
if (sb != null) {
localePath = sb.getDataPath("locale.translated_html", "DATA/LOCALE/htroot");
else
} else {
localePath = new File ("DATA/LOCALE/htroot");
List<String> dirlist = new ArrayList<String>(); // get list of language subdirectories
File[] list = localePath.listFiles();
for (File f : list) {
if (f.isDirectory()) dirlist.add(f.getName()); // filter directories to add to result
}
final List<String> dirlist = new ArrayList<String>(); // get list of language subdirectories
if(localePath.isDirectory()) {
final File[] list = localePath.listFiles();
if(list != null) { // the list may be null on IO error
for (final File f : list) {
if (f.isDirectory()) {
dirlist.add(f.getName()); // filter directories to add to result
}
}
}
}
return dirlist;
}