mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 14:30:56 +03:00
FileChooser: show localized text for all locales supported by Metal (issue #680)
This commit is contained in:
@@ -15,6 +15,8 @@ FlatLaf Change Log
|
|||||||
rendering and uses less memory compared to svgSalamander. (PR #684)
|
rendering and uses less memory compared to svgSalamander. (PR #684)
|
||||||
- ComboBox: Improved location of selected item in popup if list is large and
|
- ComboBox: Improved location of selected item in popup if list is large and
|
||||||
scrollable.
|
scrollable.
|
||||||
|
- FileChooser: Show localized text for all locales supported by Java's Metal
|
||||||
|
look and feel. (issue #680)
|
||||||
- Added system property `flatlaf.useNativeLibrary` to allow disabling loading of
|
- Added system property `flatlaf.useNativeLibrary` to allow disabling loading of
|
||||||
FlatLaf native library. (issue #674)
|
FlatLaf native library. (issue #674)
|
||||||
- IntelliJ Themes:
|
- IntelliJ Themes:
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ import javax.swing.plaf.FontUIResource;
|
|||||||
import javax.swing.plaf.IconUIResource;
|
import javax.swing.plaf.IconUIResource;
|
||||||
import javax.swing.plaf.UIResource;
|
import javax.swing.plaf.UIResource;
|
||||||
import javax.swing.plaf.basic.BasicLookAndFeel;
|
import javax.swing.plaf.basic.BasicLookAndFeel;
|
||||||
|
import javax.swing.plaf.metal.MetalLookAndFeel;
|
||||||
import javax.swing.text.StyleContext;
|
import javax.swing.text.StyleContext;
|
||||||
import javax.swing.text.html.HTMLEditorKit;
|
import javax.swing.text.html.HTMLEditorKit;
|
||||||
import com.formdev.flatlaf.ui.FlatNativeWindowBorder;
|
import com.formdev.flatlaf.ui.FlatNativeWindowBorder;
|
||||||
@@ -543,7 +544,7 @@ public abstract class FlatLaf
|
|||||||
// which can happen in applications that use some plugin system
|
// which can happen in applications that use some plugin system
|
||||||
// and load FlatLaf in a plugin that uses its own classloader.
|
// and load FlatLaf in a plugin that uses its own classloader.
|
||||||
// (e.g. Apache NetBeans)
|
// (e.g. Apache NetBeans)
|
||||||
if( defaults.get( "FileChooser.fileNameHeaderText" ) != null )
|
if( defaults.get( "TabbedPane.moreTabsButtonToolTipText" ) != null )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// load FlatLaf resource bundle and add content to defaults
|
// load FlatLaf resource bundle and add content to defaults
|
||||||
@@ -1431,26 +1432,36 @@ public abstract class FlatLaf
|
|||||||
private class FlatUIDefaults
|
private class FlatUIDefaults
|
||||||
extends UIDefaults
|
extends UIDefaults
|
||||||
{
|
{
|
||||||
|
private UIDefaults metalDefaults;
|
||||||
|
|
||||||
FlatUIDefaults( int initialCapacity, float loadFactor ) {
|
FlatUIDefaults( int initialCapacity, float loadFactor ) {
|
||||||
super( initialCapacity, loadFactor );
|
super( initialCapacity, loadFactor );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object get( Object key ) {
|
public Object get( Object key ) {
|
||||||
Object value = getValue( key );
|
return get( key, null );
|
||||||
return (value != null) ? (value != NULL_VALUE ? value : null) : super.get( key );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object get( Object key, Locale l ) {
|
public Object get( Object key, Locale l ) {
|
||||||
Object value = getValue( key );
|
Object value = getFromUIDefaultsGetters( key );
|
||||||
return (value != null) ? (value != NULL_VALUE ? value : null) : super.get( key, l );
|
if( value != null )
|
||||||
|
return (value != NULL_VALUE) ? value : null;
|
||||||
|
|
||||||
|
value = super.get( key, l );
|
||||||
|
if( value != null )
|
||||||
|
return value;
|
||||||
|
|
||||||
|
// get file chooser texts from Metal
|
||||||
|
return (key instanceof String && ((String)key).startsWith( "FileChooser." ))
|
||||||
|
? getFromMetal( (String) key, l )
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getValue( Object key ) {
|
private Object getFromUIDefaultsGetters( Object key ) {
|
||||||
// use local variable for getters to avoid potential multi-threading issues
|
// use local variable for getters to avoid potential multi-threading issues
|
||||||
List<Function<Object, Object>> uiDefaultsGetters = FlatLaf.this.uiDefaultsGetters;
|
List<Function<Object, Object>> uiDefaultsGetters = FlatLaf.this.uiDefaultsGetters;
|
||||||
|
|
||||||
if( uiDefaultsGetters == null )
|
if( uiDefaultsGetters == null )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -1462,6 +1473,22 @@ public abstract class FlatLaf
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private synchronized Object getFromMetal( String key, Locale l ) {
|
||||||
|
if( metalDefaults == null ) {
|
||||||
|
metalDefaults = new MetalLookAndFeel() {
|
||||||
|
// avoid unnecessary initialization
|
||||||
|
@Override protected void initClassDefaults( UIDefaults table ) {}
|
||||||
|
@Override protected void initSystemColorDefaults( UIDefaults table ) {}
|
||||||
|
}.getDefaults();
|
||||||
|
|
||||||
|
// empty not needed defaults (to save memory) because we're only interested
|
||||||
|
// in resource bundle strings, which are stored in another internal map
|
||||||
|
metalDefaults.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
return metalDefaults.get( key, l );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---- class ActiveFont ---------------------------------------------------
|
//---- class ActiveFont ---------------------------------------------------
|
||||||
|
|||||||
@@ -12,42 +12,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
#---- FileChooser ----
|
|
||||||
|
|
||||||
#fields
|
|
||||||
FileChooser.lookInLabel.textAndMnemonic = Look &In:
|
|
||||||
FileChooser.saveInLabelText = Save In:
|
|
||||||
FileChooser.fileNameLabel.textAndMnemonic = File &Name:
|
|
||||||
FileChooser.folderNameLabel.textAndMnemonic = Folder &name:
|
|
||||||
FileChooser.filesOfTypeLabel.textAndMnemonic = Files of &Type:
|
|
||||||
|
|
||||||
# toolbar
|
|
||||||
FileChooser.upFolderToolTipText = Up One Level
|
|
||||||
FileChooser.upFolderAccessibleName = Up
|
|
||||||
FileChooser.homeFolderToolTipText = Home
|
|
||||||
FileChooser.homeFolderAccessibleName = Home
|
|
||||||
FileChooser.newFolderToolTipText = Create New Folder
|
|
||||||
FileChooser.newFolderAccessibleName = New Folder
|
|
||||||
FileChooser.listViewButtonToolTipText = List
|
|
||||||
FileChooser.listViewButtonAccessibleName = List
|
|
||||||
FileChooser.detailsViewButtonToolTipText = Details
|
|
||||||
FileChooser.detailsViewButtonAccessibleName = Details
|
|
||||||
|
|
||||||
# details table header
|
|
||||||
FileChooser.fileNameHeaderText = Name
|
|
||||||
FileChooser.fileSizeHeaderText = Size
|
|
||||||
FileChooser.fileTypeHeaderText = Type
|
|
||||||
FileChooser.fileDateHeaderText = Modified
|
|
||||||
FileChooser.fileAttrHeaderText = Attributes
|
|
||||||
|
|
||||||
# popup menu
|
|
||||||
FileChooser.viewMenuLabelText = View
|
|
||||||
FileChooser.refreshActionLabelText = Refresh
|
|
||||||
FileChooser.newFolderActionLabelText = New Folder
|
|
||||||
FileChooser.listViewActionLabelText = List
|
|
||||||
FileChooser.detailsViewActionLabelText = Details
|
|
||||||
|
|
||||||
|
|
||||||
#---- SplitPaneDivider ----
|
#---- SplitPaneDivider ----
|
||||||
|
|
||||||
SplitPaneDivider.collapseLeftToolTipText = Collapse Left Pane
|
SplitPaneDivider.collapseLeftToolTipText = Collapse Left Pane
|
||||||
|
|||||||
@@ -12,42 +12,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
#---- FileChooser ----
|
|
||||||
|
|
||||||
#fields
|
|
||||||
FileChooser.lookInLabel.textAndMnemonic = Suchen &in:
|
|
||||||
FileChooser.saveInLabelText = Speichern in:
|
|
||||||
FileChooser.fileNameLabel.textAndMnemonic = &Dateiname:
|
|
||||||
FileChooser.folderNameLabel.textAndMnemonic = Ordner&name:
|
|
||||||
FileChooser.filesOfTypeLabel.textAndMnemonic = Datei&typ:
|
|
||||||
|
|
||||||
# toolbar
|
|
||||||
FileChooser.upFolderToolTipText = Eine Ebene h\u00F6her
|
|
||||||
FileChooser.upFolderAccessibleName = Nach oben
|
|
||||||
FileChooser.homeFolderToolTipText = Home
|
|
||||||
FileChooser.homeFolderAccessibleName = Home
|
|
||||||
FileChooser.newFolderToolTipText = Neuen Ordner erstellen
|
|
||||||
FileChooser.newFolderAccessibleName = Neuer Ordner
|
|
||||||
FileChooser.listViewButtonToolTipText = Liste
|
|
||||||
FileChooser.listViewButtonAccessibleName = Liste
|
|
||||||
FileChooser.detailsViewButtonToolTipText = Details
|
|
||||||
FileChooser.detailsViewButtonAccessibleName = Details
|
|
||||||
|
|
||||||
# details table header
|
|
||||||
FileChooser.fileNameHeaderText = Name
|
|
||||||
FileChooser.fileSizeHeaderText = Gr\u00F6\u00DFe
|
|
||||||
FileChooser.fileTypeHeaderText = Typ
|
|
||||||
FileChooser.fileDateHeaderText = \u00C4nderungsdatum
|
|
||||||
FileChooser.fileAttrHeaderText = Attribute
|
|
||||||
|
|
||||||
# popup menu
|
|
||||||
FileChooser.viewMenuLabelText = Ansicht
|
|
||||||
FileChooser.refreshActionLabelText = Aktualisieren
|
|
||||||
FileChooser.newFolderActionLabelText = Neuer Ordner
|
|
||||||
FileChooser.listViewActionLabelText = Liste
|
|
||||||
FileChooser.detailsViewActionLabelText = Details
|
|
||||||
|
|
||||||
|
|
||||||
#---- TabbedPane ----
|
#---- TabbedPane ----
|
||||||
|
|
||||||
TabbedPane.moreTabsButtonToolTipText = Verdeckte Tabs anzeigen
|
TabbedPane.moreTabsButtonToolTipText = Verdeckte Tabs anzeigen
|
||||||
|
|||||||
@@ -12,42 +12,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
#---- FileChooser ----
|
|
||||||
|
|
||||||
#fields
|
|
||||||
FileChooser.lookInLabel.textAndMnemonic = Buscar &en:
|
|
||||||
FileChooser.saveInLabelText = Guardar en:
|
|
||||||
FileChooser.fileNameLabel.textAndMnemonic = &Nombre de fichero:
|
|
||||||
FileChooser.folderNameLabel.textAndMnemonic = &Nombre de carpeta:
|
|
||||||
FileChooser.filesOfTypeLabel.textAndMnemonic = Ficheros de &Tipo:
|
|
||||||
|
|
||||||
# toolbar
|
|
||||||
FileChooser.upFolderToolTipText = Subir un nivel
|
|
||||||
FileChooser.upFolderAccessibleName = Subir
|
|
||||||
FileChooser.homeFolderToolTipText = Inicio
|
|
||||||
FileChooser.homeFolderAccessibleName = Inicio
|
|
||||||
FileChooser.newFolderToolTipText = Crear nueva carpeta
|
|
||||||
FileChooser.newFolderAccessibleName = Nueva carpeta
|
|
||||||
FileChooser.listViewButtonToolTipText = Lista
|
|
||||||
FileChooser.listViewButtonAccessibleName = Lista
|
|
||||||
FileChooser.detailsViewButtonToolTipText = Detalles
|
|
||||||
FileChooser.detailsViewButtonAccessibleName = Detalles
|
|
||||||
|
|
||||||
# details table header
|
|
||||||
FileChooser.fileNameHeaderText = Nombre
|
|
||||||
FileChooser.fileSizeHeaderText = Tama\u00F1o
|
|
||||||
FileChooser.fileTypeHeaderText = Tipo
|
|
||||||
FileChooser.fileDateHeaderText = Modificado
|
|
||||||
FileChooser.fileAttrHeaderText = Atributos
|
|
||||||
|
|
||||||
# popup menu
|
|
||||||
FileChooser.viewMenuLabelText = Ver
|
|
||||||
FileChooser.refreshActionLabelText = Refrescar
|
|
||||||
FileChooser.newFolderActionLabelText = Nueva carpeta
|
|
||||||
FileChooser.listViewActionLabelText = Lista
|
|
||||||
FileChooser.detailsViewActionLabelText = Detalles
|
|
||||||
|
|
||||||
|
|
||||||
#---- SplitPaneDivider ----
|
#---- SplitPaneDivider ----
|
||||||
|
|
||||||
SplitPaneDivider.collapseLeftToolTipText = Contraer Panel Izquierdo
|
SplitPaneDivider.collapseLeftToolTipText = Contraer Panel Izquierdo
|
||||||
|
|||||||
@@ -12,37 +12,3 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
#---- FileChooser ----
|
|
||||||
|
|
||||||
#fields
|
|
||||||
FileChooser.lookInLabel.textAndMnemonic = Rechercher &dans:
|
|
||||||
FileChooser.saveInLabelText = Enregistrer dans:
|
|
||||||
FileChooser.fileNameLabel.textAndMnemonic = &Nom du fichier:
|
|
||||||
FileChooser.folderNameLabel.textAndMnemonic = &Nom du dossier:
|
|
||||||
FileChooser.filesOfTypeLabel.textAndMnemonic = &Type de fichier:
|
|
||||||
|
|
||||||
# toolbar
|
|
||||||
FileChooser.upFolderToolTipText = Remonte d'un niveau
|
|
||||||
FileChooser.upFolderAccessibleName = Monter
|
|
||||||
FileChooser.homeFolderToolTipText = R\u00E9pertoire de base
|
|
||||||
FileChooser.homeFolderAccessibleName = R\u00E9pertoire de base
|
|
||||||
FileChooser.newFolderToolTipText = Cr\u00E9e un dossier
|
|
||||||
FileChooser.newFolderAccessibleName = Nouveau dossier
|
|
||||||
FileChooser.listViewButtonToolTipText = Liste
|
|
||||||
FileChooser.listViewButtonAccessibleName = Liste
|
|
||||||
FileChooser.detailsViewButtonToolTipText = D\u00E9tails
|
|
||||||
FileChooser.detailsViewButtonAccessibleName = D\u00E9tails
|
|
||||||
|
|
||||||
# details table header
|
|
||||||
FileChooser.fileNameHeaderText = Nom
|
|
||||||
FileChooser.fileSizeHeaderText = Taille
|
|
||||||
FileChooser.fileTypeHeaderText = Type
|
|
||||||
FileChooser.fileDateHeaderText = Modifi\u00E9
|
|
||||||
FileChooser.fileAttrHeaderText = Attributs
|
|
||||||
|
|
||||||
# popup menu
|
|
||||||
FileChooser.viewMenuLabelText = Affichage
|
|
||||||
FileChooser.refreshActionLabelText = Actualiser
|
|
||||||
FileChooser.newFolderActionLabelText = Nouveau dossier
|
|
||||||
FileChooser.listViewActionLabelText = Liste
|
|
||||||
FileChooser.detailsViewActionLabelText = D\u00E9tails
|
|
||||||
|
|||||||
@@ -33,6 +33,13 @@ public class FlatChooserTest
|
|||||||
extends FlatTestPanel
|
extends FlatTestPanel
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) {
|
public static void main( String[] args ) {
|
||||||
|
// Locale.setDefault( Locale.FRENCH );
|
||||||
|
// Locale.setDefault( Locale.GERMAN );
|
||||||
|
// Locale.setDefault( Locale.ITALIAN );
|
||||||
|
// Locale.setDefault( Locale.JAPANESE );
|
||||||
|
// Locale.setDefault( Locale.SIMPLIFIED_CHINESE );
|
||||||
|
// Locale.setDefault( Locale.TRADITIONAL_CHINESE );
|
||||||
|
|
||||||
SwingUtilities.invokeLater( () -> {
|
SwingUtilities.invokeLater( () -> {
|
||||||
FlatTestFrame frame = FlatTestFrame.create( args, "FlatChooserTest" );
|
FlatTestFrame frame = FlatTestFrame.create( args, "FlatChooserTest" );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user