L& F中字符串键的位置 [英] Location of String keys in L&F

查看:127
本文介绍了L& F中字符串键的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java中有几个组件具有预定义的外观和自动打印在其上的文本字符串。示例是JFileChooser。

There are several components in Java that have predefined look and strings of text that are automatically printed on them. Examples is JFileChooser.

此外,当您尝试在JFileChooser中进行非法重命名时,会弹出一个JDialog(或JOptionPane)...

Also, there is a JDialog (or JOptionPane) that pops up when you try to do illegale rename in JFileChooser...

在什么* .java文件中可以使用表示该键的键字符串以及它们在何处获取其值?

In what *.java file(s) can string keys that represent that keys and where do they get their values?

我是我正在谈论Nimbus L& F ......我找不到他们在Nimbus和Synth(这并不意味着他们不在那里)......我确实在BasicFileChooser中找到了JFileChooser字符串。

I'm talking about Nimbus L&F... I couldn't locate them in Nimbus nor Synth (which doesn't necessary mean they're not there)... I did found JFileChooser Strings in BasicFileChooser.

底线:
我正在翻译我的程序,我不想要任何意外,所以我想知道哪些组件有预定义的字符串以及在哪里找到它们,来自上面的JDialog尤其...

Bottom line: I'm translating my program and I don't want any surprises, so I'd like to know which components have predefined strings and where to find them, that JDialog from above especially...

编辑:
我找到了BasicFileChooserUI,这是其中一种方法:

I have found BasicFileChooserUI, and this is one of the methods:

protected void installStrings(JFileChooser fc) {

    Locale l = fc.getLocale();
    newFolderErrorText = UIManager.getString("FileChooser.newFolderErrorText",l);
    newFolderErrorSeparator = UIManager.getString("FileChooser.newFolderErrorSeparator",l);

    newFolderParentDoesntExistTitleText = UIManager.getString("FileChooser.newFolderParentDoesntExistTitleText", l);
    newFolderParentDoesntExistText = UIManager.getString("FileChooser.newFolderParentDoesntExistText", l);

    fileDescriptionText = UIManager.getString("FileChooser.fileDescriptionText",l);
    directoryDescriptionText = UIManager.getString("FileChooser.directoryDescriptionText",l);

    saveButtonText   = UIManager.getString("FileChooser.saveButtonText",l);
    openButtonText   = UIManager.getString("FileChooser.openButtonText",l);
    saveDialogTitleText = UIManager.getString("FileChooser.saveDialogTitleText",l);
    openDialogTitleText = UIManager.getString("FileChooser.openDialogTitleText",l);
    cancelButtonText = UIManager.getString("FileChooser.cancelButtonText",l);
    updateButtonText = UIManager.getString("FileChooser.updateButtonText",l);
    helpButtonText   = UIManager.getString("FileChooser.helpButtonText",l);
    directoryOpenButtonText = UIManager.getString("FileChooser.directoryOpenButtonText",l);

    saveButtonMnemonic   = getMnemonic("FileChooser.saveButtonMnemonic", l);
    openButtonMnemonic   = getMnemonic("FileChooser.openButtonMnemonic", l);
    cancelButtonMnemonic = getMnemonic("FileChooser.cancelButtonMnemonic", l);
    updateButtonMnemonic = getMnemonic("FileChooser.updateButtonMnemonic", l);
    helpButtonMnemonic   = getMnemonic("FileChooser.helpButtonMnemonic", l);
    directoryOpenButtonMnemonic = getMnemonic("FileChooser.directoryOpenButtonMnemonic", l);

    saveButtonToolTipText   = UIManager.getString("FileChooser.saveButtonToolTipText",l);
    openButtonToolTipText   = UIManager.getString("FileChooser.openButtonToolTipText",l);
    cancelButtonToolTipText = UIManager.getString("FileChooser.cancelButtonToolTipText",l);
    updateButtonToolTipText = UIManager.getString("FileChooser.updateButtonToolTipText",l);
    helpButtonToolTipText   = UIManager.getString("FileChooser.helpButtonToolTipText",l);
    directoryOpenButtonToolTipText = UIManager.getString("FileChooser.directoryOpenButtonToolTipText",l);
}

我想知道 getString的位置( FileChooser.updateButtonText,l)拉出字符串的方法......我试着找它,但我没有运气...
另外,我知道JFileChooser中有一些字符串BasicFileChooserUI.java中未定义...

I want to know from where is the getString("FileChooser.updateButtonText",l) method pulling out strings... I tried looking for it, but I had no luck... Also, I know there are some strings in JFileChooser that are not defined in BasicFileChooserUI.java...

推荐答案

许多此类用户界面元素已针对支持的语言进行了本地化,如图所示在 JDK 6和JRE 6支持的语言环境:用户界面翻译

Many such user interface elements are already localized for supported languages, as shown in JDK 6 and JRE 6 Supported Locales: User Interface Translation.

附录:另见 国际化:了解Java平台中的区域设置 。未指定 UIManager.getLookAndFeelDefaults()获取L& F默认值的方式;不支持更改源数据。在返回的 Map 中找到的属性的(非本地化)名称可用于覆盖默认值。如 如何编写自定义外观 ,源文本存储在每个L& F和每个支持的语言环境的属性文件中。 QuaQua 就是一个例子。例如,在我的平台上, com.apple.laf.AquaLookAndFeel 的英文字符串位于

Addenda: See also Internationalization: Understanding Locale in the Java Platform. The manner in which UIManager.getLookAndFeelDefaults() obtains the L&F defaults is not specified; changing the source data is not supported. The (non-localized) names of the properties found in the returned Map may be used to override the defaults. As discussed in How to Write a Custom Look and Feel, the source text is stored in a properties file for each L&F and each supported locale. QuaQua is an example. On my platform, for example, the English strings for com.apple.laf.AquaLookAndFeel are in


$JAVA_HOME/Resources/English.lproj/aqua.properties

警告:


# When this file is read in, the strings are put into the 
# defaults table.  This is an implementation detail of the current
# workings of Swing.  DO NOT DEPEND ON THIS.  This may change in
# future versions of Swing as we improve localization support.

另见 我该怎么办?对于 JFileChooser ,为默认情况下不支持的区域设置添加本地化

See also How can I add localization to JFileChooser for a locale that is not supported by default?

这篇关于L& F中字符串键的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆