RFR: 8312075: FileChooser.win32.newFolder is not updated when changing Locale
Alexey Ivanov
aivanov at openjdk.org
Fri Aug 4 13:06:35 UTC 2023
On Fri, 28 Jul 2023 10:56:47 GMT, Tejesh R <tr at openjdk.org> wrote:
> On `NewFolderAction`, plain String is added `Action.ACTION_COMMAND_KEY`. Converting the `String `to `locale` before adding as command key fix the issue.
> I have verified the test in all other platforms and Look and Feel which has option to create New Folder, results were fine. No regressions found on CI system with the fix. Added manual test to verify the fix.
src/java.desktop/share/classes/sun/swing/FilePane.java line 1595:
> 1593: String newFolderText = UIManager.getString(FilePane.ACTION_NEW_FOLDER,
> 1594: getFileChooser().getLocale());
> 1595: putValue(Action.ACTION_COMMAND_KEY, newFolderText);
I doubt this is the right thing to do. `ACTION_COMMAND_KEY` aren't localisable as far as I can see, and it makes perfect sense — they identify internal names of the commands.
The tooltip of the command and the created folder name are localisable.
If I run SwingSet2 in German locale, it works as expected: the tooltip of the New folder command is displayed in German (as the entire interface of `JFileChooser`) and the created folder has German name.
Start SwingSet2 with this command:
java -Duser.language=de -Duser.country=DE -jar /SwingSet2.jar
test/jdk/javax/swing/JFileChooser/NewFolderLocale/FileChooserNewFolderLocaleTest.java line 1:
> 1: /*
Can't the test be automatic? After you display the file chooser, you can find the "New folder" button and click it programmatically or get New Folder Action and invoke it. If you display the file chooser in the known directory, the current one seems a good option, and it should be empty when running with jtreg, you can verify the name of new folder created.
test/jdk/javax/swing/JFileChooser/NewFolderLocale/FileChooserNewFolderLocaleTest.java line 66:
> 64:
> 65: private static void initialize() throws Exception {
> 66: setLocale("fr");
Is it about locale change on the fly? Does it work correctly if you set locale using JVM parameters:
java -Duser.language=fr -Duser.country=FR <className>
test/jdk/javax/swing/JFileChooser/NewFolderLocale/FileChooserNewFolderLocaleTest.java line 103:
> 101:
> 102: res = ResourceBundle.getBundle("bundle", new Locale(locale));
> 103: UIManager.put("FileChooser.acceptAllFileFilterText", res.getString("accept_all"));
Doesn't UIManager loads its resource bundles? It should be possible to provide your own extension to existing resource bundles.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15069#discussion_r1284374188
PR Review Comment: https://git.openjdk.org/jdk/pull/15069#discussion_r1284390285
PR Review Comment: https://git.openjdk.org/jdk/pull/15069#discussion_r1284365924
PR Review Comment: https://git.openjdk.org/jdk/pull/15069#discussion_r1284386749
More information about the client-libs-dev
mailing list