Ignore:
Timestamp:
2008-10-10T09:05:07+13:00 (16 years ago)
Author:
oranfry
Message:

changes to the way ant-installer loads and reloads the language packs, and a new attribute to the select input which triggers it to change the language to the input value

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release-kits/shared/ant-installer/src/org/tp23/antinstaller/input/SelectInput.java

    r14982 r17514  
    1919import java.util.MissingResourceException;
    2020import java.util.ResourceBundle;
    21 
     21import java.util.Locale;
    2222import org.tp23.antinstaller.InstallerContext;
    2323import org.tp23.antinstaller.ValidationException;
    24 
     24import org.tp23.antinstaller.Installer;
    2525
    2626
     
    3535 */
    3636public class SelectInput
    37     extends InputField{
     37    extends InputField {
    3838
    39     // i18n support
    40     private static ResourceBundle langPack = null;
    4139    private int optionIdx = 0;
    42     static{
    43         try {
    44             langPack = ResourceBundle.getBundle("resources.LanguagePack");
    45         } catch (MissingResourceException e) {
    46             // ignore, signifies no lang packs installed 
    47         }
     40    private SelectInput.Option[] options;
     41    private boolean useAsLocale = false;
     42
     43    public SelectInput() {
    4844    }
    4945
    50     private SelectInput.Option[] options;
    51 
    52     public SelectInput() {
     46    public void setUseAsLocale(boolean ual) {
     47        this.useAsLocale = ual;
    5348    }
    5449
     
    7570        }
    7671        public String getText() {
    77             if(langPack != null){
    78                 return langPack.getString(getProperty() + "." + idx +".displayText");
     72            if( org.tp23.antinstaller.Installer.langPack != null ){
     73                return org.tp23.antinstaller.Installer.langPack.getString(getProperty() + "." + idx +".displayText");
    7974            }
    8075            return text;
     
    8479    public void setValue(String value){
    8580        setInputResult(value);
     81        if ( useAsLocale ) {
     82            //expect something like 'en' or or something like 'en_US'
     83            if ( value.length() == 2 ) {
     84                Locale.setDefault( new Locale(value) );
     85            } else if ( value.length() == 5 ) {
     86                Locale.setDefault( new Locale(value.substring(0,2), value.substring(3,5)) );
     87            } //else { you're out of luck }
     88            org.tp23.antinstaller.Installer.langPack = ResourceBundle.getBundle("resources.LanguagePack");
     89        }
    8690    }
    8791   
Note: See TracChangeset for help on using the changeset viewer.