views:

20

answers:

1

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?

+1  A: 

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
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
AFAIK, I'm afraid you have to check the locale and set up the new values manually.
Colin Hebert
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
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