The list of supported locales for User Interface Translation does not have all the languages I need to support.  How can I add more languages for a JFileChooser?
            Asked
            
        
        
            Active
            
        
            Viewed 5,694 times
        
    13
            
            
        
        trashgod
        
- 203,806
 - 29
 - 246
 - 1,045
 
        Tony Eichelberger
        
- 7,044
 - 7
 - 37
 - 46
 
2 Answers
14
            In fact it is possible to use properties file to translate standard Swing strings. Just call
UIManager.getDefaults().addResourceBundle("com.mypackage.messages");
where com.mypackage.messages is a fully-qualified bundle base name.
        Grey Teardrop
        
- 511
 - 6
 - 11
 
12
            
            
        You can change the properties of your JFileChooser like FileChooser.openButtonText
UIManager.put("FileChooser.acceptAllFileFilterText", "Directorios");
UIManager.put("FileChooser.lookInLabelText", "Localização");
UIManager.put("FileChooser.cancelButtonText", "Cancelar");
UIManager.put("FileChooser.cancelButtonToolTipText", "Cancelar");
UIManager.put("FileChooser.openButtonText", "Adicionar");
UIManager.put("FileChooser.openButtonToolTipText", "Adicionar ficheiro(s)");
UIManager.put("FileChooser.filesOfTypeLabelText", "Tipo");
UIManager.put("FileChooser.fileNameLabelText", "Ficheiro(s)");
UIManager.put("FileChooser.listViewButtonToolTipText", "Lista"); 
UIManager.put("FileChooser.listViewButtonAccessibleName", "Lista"); 
UIManager.put("FileChooser.detailsViewButtonToolTipText", "Detalhes");
UIManager.put("FileChooser.detailsViewButtonAccessibleName", "Detalhes");
UIManager.put("FileChooser.upFolderToolTipText", "Um nível acima"); 
UIManager.put("FileChooser.upFolderAccessibleName", "Um nível acima"); 
UIManager.put("FileChooser.homeFolderToolTipText", "Ambiente de Trabalho"); 
UIManager.put("FileChooser.homeFolderAccessibleName", "Ambiente de Trabalho"); UIManager.put("FileChooser.fileNameHeaderText", "Nome"); 
UIManager.put("FileChooser.fileSizeHeaderText", "Tamanho"); 
UIManager.put("FileChooser.fileTypeHeaderText", "Tipo"); 
UIManager.put("FileChooser.fileDateHeaderText", "Data"); 
UIManager.put("FileChooser.fileAttrHeaderText", "Atributos"); 
UIManager.put("FileChooser.openDialogTitleText","Adicionar Fotos");
UIManager.put("FileChooser.readOnly", Boolean.TRUE);
Resources :
        Colin Hebert
        
- 91,525
 - 15
 - 160
 - 151
 
- 
                    so, is there any way to put this in a propeties file so the correct locale choosing logic will be performed? I could add a check in code for the locales I am looking for but I would rather have the jvm choose the right file for me. – Tony Eichelberger Sep 08 '10 at 21:26
 - 
                    AFAIK, I'm afraid you have to check the locale and set up the new values manually. – Colin Hebert Sep 08 '10 at 21:39
 - 
                    You can subclass JFileChooser, add similar code in static initialization block (required) and then you can export these values to properties just as you always do. – Paweł Dyda Sep 09 '10 at 07:21
 - 
                    There is also a way to externalize mnemonics this way but it won't be so easy to find. By the way: in JDK 6 home folder (desktop) comes from OS, so there is no way to translate it (Vista and above will always show you English name) – Paweł Dyda Sep 09 '10 at 07:23