United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7093156 NLS: Please change the mnemonic assignment system to avoid translation issue (Swing files)
JDK-7093156 : NLS: Please change the mnemonic assignment system to avoid translation issue (Swing files)

Details
Type:
Bug
Submit Date:
2011-09-21
Status:
Closed
Updated Date:
2013-07-16
Project Name:
JDK
Resolved Date:
2012-06-21
Component:
client-libs
OS:
generic
Sub-Component:
javax.swing
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

Description
WPTG (translation team) translatability (t13y) requirement:

When designing GUI that includes mnemonics, please define the text label and
mnemonic character in one resource, with the mnemonic character preceded by
ampersand (&).

DO THIS

English :  

MENU_TEXT_AND_MNEMONIC=&File

Japanese :  

MENU_TEXT_AND_MNEMONIC=ファイル(&F)


DO NOT DO THIS

English :  

MENU_TEXT=File
MENU_MNEMONIC=F

Japanese :  

MENU_TEXT=ファイル(F)
MENU_MNEMONIC=F


The issue has been identified on the following Swing files:
jdk/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk.properties
jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic.properties
jdk/src/closed/share/demo/jfc/SwingSet2/resources/swingset.properties
This issue also impacts:
jdk/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal.properties

                                    

Comments
EVALUATION

According to the bug pre-processing/post-processing property files is considered as unreliable and it is suggested to not do that for jdk8.


There is the following format in the swing *.properties files now:

-------------------------------------------------------
FileChooser.updateButtonText=Update
FileChooser.updateButtonMnemonic=85
-------------------------------------------------------

We can't change this property to FileChooser.updateButtonText=&Update because users are able to override this property by UIManager.put(key, value) method.
So it is a valid case to use the & in a text and it is expected that this symbol is shown. There will be a regression if we do not show this symbol.

So we need to introduce new properties like FileChooser.localized.updateButtonText and support both formats. If a user use the old format than we need to process it in other case we need to parse new format.

So it seems that there is big work that includes following changes:
- L&F UI for JLabel AbstractButton JColorChooser JFileChooser JTabbedPane components
- Basic and Metal L&Fs and synthetic property files
- property files for different localizations: default, de, es, fr, it, ja, ko, pt_BR, sv, zh_CN, zh_TW.


The second question is a public API to allow users to use & symbol for mnemonics.
It looks like we need to add method like setLocalizationText(String text) for components with the setDisplayedMnemonic() method (JLabel AbstractButton JColorChooser JFileChooser JTabbedPane components) .
There are some questions about it:
- How the text should look like if it needs to use & in the text?
- How do we want to process html text that can contain symbols like < ?
                                     
2012-02-29
EVALUATION

The demo propertis updating is covered by issue 7158926
The macosx properties updating is covered by the issue 7158928

Now all properties are generated with the following suffixes: xxx.textAndMnemonic and xxx.titleAndMnemonic
- patterns which are generated to properties with the xxx.textAndMnemonic suffix:
  (xxxNameText, xxxNameMnemonic)
  (xxxNameText, xxxMnemonic)
  (xxx.nameText, xxx.mnemonic)
  (xxxText, xxxMnemonic)

- pattern which is generated to properties with the xxx.titleAndMnemonic suffix:
   (xxxTitle, xxxMnemonic)

After that the extended hashmap check a key suffix and generate a compositeKey which allows to get a property in a new format and extract a text, mnemonic or mnemonic index from it. 

 The attached SwingResourcesTest test gets a path to the old properties and L&F class. If L&F is not null than it is set. After that the test gets all properties and it's values and check that values are equal to the values which are got from the  UIManager.get(key, locale).
                                     
2012-04-04
EVALUATION

changeset: http://hg.openjdk.java.net/jdk8/awt/jdk/rev/cbf39e7a7535
                                     
2012-04-04
EVALUATION

.
                                     
2012-06-21



Hardware and Software, Engineered to Work Together