Changeset 20961

Show
Ignore:
Timestamp:
18.11.2009 19:33:58 (10 years ago)
Author:
ak19
Message:

Now when GLI starts up and finds a language in the config file which GLI does not yet support, and when Preferences is opened and a property changed, it no longer defaults to the first available language in the list (Arabic), but defaults to English instead. The Configuration file is also updated to English, so it doesn't force a restart on the GLI user.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gli/trunk/src/org/greenstone/gatherer/gui/Preferences.java

    r20789 r20961  
    406406    for(int i = 0; i < language_elements.getLength(); i++) { 
    407407        Element language_element = (Element) language_elements.item(i); 
    408         if((language_element.getAttribute(StaticStrings.GLI_ATTRIBUTE)).equalsIgnoreCase(StaticStrings.TRUE_STR) || (language_element.getAttribute(StaticStrings.MDS_ATTRIBUTE)).equalsIgnoreCase(StaticStrings.TRUE_STR)) { 
     408        if((language_element.hasAttribute(StaticStrings.GLI_ATTRIBUTE)  
     409        && (language_element.getAttribute(StaticStrings.GLI_ATTRIBUTE)).equalsIgnoreCase(StaticStrings.TRUE_STR))  
     410           || (language_element.hasAttribute(StaticStrings.MDS_ATTRIBUTE)  
     411           && (language_element.getAttribute(StaticStrings.MDS_ATTRIBUTE)).equalsIgnoreCase(StaticStrings.TRUE_STR))) 
     412        { 
    409413        Locale locale = new Locale(language_element.getAttribute(StaticStrings.CODE_ATTRIBUTE)); 
    410414        String description = language_element.getAttribute(StaticStrings.NAME_ATTRIBUTE); 
     
    480484         
    481485    // Try to locate and select the current language 
     486    // Else default to English 
    482487    String language_code = Configuration.getLanguage(); 
    483     for (int b = 0; b < language_combobox.getItemCount(); b++) { 
     488    int defaultIndex = 0; 
     489    DictionaryEntry defaultEntry = null; 
     490 
     491    int b = 0; 
     492    for (; b < language_combobox.getItemCount(); b++) { 
    484493        DictionaryEntry entry = (DictionaryEntry) language_combobox.getItemAt(b); 
    485494        if (language_code.equalsIgnoreCase(entry.getLocale().getLanguage())) { 
    486495        language_combobox.setSelectedIndex(b); 
    487496        break; 
    488         } 
     497        } else if (entry.getLocale().getLanguage().equalsIgnoreCase("en")) { // store English as fallback 
     498        defaultIndex = b; 
     499        defaultEntry = entry; 
     500        } 
     501    } 
     502    // if we cycled through and couldn't find the chosen language to load,  
     503    // then we set the Preferences' and Configuration's language to English 
     504    if (b == language_combobox.getItemCount()) { 
     505        language_combobox.setSelectedIndex(defaultIndex); 
     506        Configuration.setLocale("general.locale", true, defaultEntry.getLocale()); 
     507        System.err.println("*** GLI doesn't yet support the language: " + language_code  
     508                   + " and has therefore defaulted to: " + Configuration.getLanguage()); 
    489509    } 
    490510