Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7093156

NLS: Please change the mnemonic assignment system to avoid translation issue (Swing files)

    Details

    • Subcomponent:
    • Resolved In Build:
      b34
    • CPU:
      generic
    • OS:
      generic

      Backports

        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

          Issue Links

            Activity

            Hide
            alexsch Alexander Scherbatiy (Inactive) added a comment -
            BT2: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 < ?
            Show
            alexsch Alexander Scherbatiy (Inactive) added a comment - BT2: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 < ?
            Hide
            alexsch Alexander Scherbatiy (Inactive) added a comment -
            BT2: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).
            Show
            alexsch Alexander Scherbatiy (Inactive) added a comment - BT2: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).
            Show
            alexsch Alexander Scherbatiy (Inactive) added a comment - BT2:EVALUATION changeset: http://hg.openjdk.java.net/jdk8/awt/jdk/rev/cbf39e7a7535
            Hide
            avorobye Alexander Vorobyev (Inactive) added a comment -
            BT2:EVALUATION

            .
            Show
            avorobye Alexander Vorobyev (Inactive) added a comment - BT2:EVALUATION .
            Hide
            alexsch Alexander Scherbatiy (Inactive) added a comment -
            There are tests that check mnemonics for Swing components:
            jdk/test/javax/swing/JMenu/4515762/bug4515762.java
            jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java
            jdk/test/javax/swing/JRootPane/4670486/bug4670486.java
            jdk/test/javax/swing/JMenu/4692443/bug4692443.java
            jdk/test/javax/swing/JLabel/6596966/bug6596966.java
            jdk/test/javax/swing/JPopupMenu/6827786/bug6827786.java
            jdk/test/javax/swing/JMenuItem/ShortcutNotDiplayed/ShortcutNotDisplayedTest.java
            jdk/test/javax/swing/JColorChooser/Test6524757.java
            Show
            alexsch Alexander Scherbatiy (Inactive) added a comment - There are tests that check mnemonics for Swing components: jdk/test/javax/swing/JMenu/4515762/bug4515762.java jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java jdk/test/javax/swing/JRootPane/4670486/bug4670486.java jdk/test/javax/swing/JMenu/4692443/bug4692443.java jdk/test/javax/swing/JLabel/6596966/bug6596966.java jdk/test/javax/swing/JPopupMenu/6827786/bug6827786.java jdk/test/javax/swing/JMenuItem/ShortcutNotDiplayed/ShortcutNotDisplayedTest.java jdk/test/javax/swing/JColorChooser/Test6524757.java

              People

              • Assignee:
                alexsch Alexander Scherbatiy (Inactive)
                Reporter:
                mfang Michael Fang (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: