Java:如何强制本地化 swt FileDialog

发布于 2024-11-05 21:56:39 字数 152 浏览 6 评论 0原文

我会将 FileDialog 组件本地化为英语。我的默认语言是意大利语。 是否可以?

我使用 FileDialog 的项目是一个 Eclipse 插件项目。

我找到了仅适用于 JFileChooser 组件的解决方案,并且它有效。

先感谢您。

I would localize a FileDialog component in English. My default language is Italian.
Is it possible?

The project where I'm using the FileDialog is an Eclipse plug-in project.

I've found the solution only for JFileChooser components and it works.

Thank you in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回心转意 2024-11-12 21:56:39

原始答案中的信息已过时。请向下滚动到编辑 2。

我的理解是 SWT 正在调用一些操作系统 API 来显示常见对话框(FileDialog 就是其中之一)。因此,它将始终以当前操作系统语言或当前用户为 MUI 系统选择的语言显示。
如果我的理解是正确的(我坚信如此),那么根本没有办法将其本地化。

编辑(贾雷克发表评论后):

看来我错了。 此页面(向下滚动到国际化)显示:

Eclipse SDK 被设计为国际化的基础
产品。 Eclipse SDK 提供的用户界面元素
组件,包括对话框和错误消息,都是外部化的。
英文字符串作为默认资源包提供。

这意味着它应该是可本地化的。但这并不意味着它是本地化的。另一句话:

测试了德语和日语语言环境。

这是否意味着它已本地化为德语和日语?我不知道。 Mac 平台上的 Swing 就是这样(我不确定现在是否还一样)。
然而,这意味着本地化至少应该是可能的。

编辑2(当前的事态)

如果一开始就是这种情况我就不能(我不这么认为),但现在你所要做的就是 使用语言包

java -Duser.language=fr -Djava.library.path=C:\MyApp
-classpath C:\MyApp\swt.jar;C:\MyApp\swt-nl.jar;C:\MyApp\myApp.jar
my.org.HelloWorld

只需在类路径上放置一个或多个语言包就足以翻译 FileDialog。如果是意大利语和其他少数语言,则为 NLpack1。对于波兰语、匈牙利语、捷克语和俄语,则为 NLpack2< /a>.

原始信息似乎是错误的,抱歉(感谢 Jarek 的质疑,它应该提高这个答案的质量)。

The information in original answer is outdated. Please scroll down to Edit 2.

My understanding is that SWT is calling some Operating System API to display common dialogs (FileDialog be one of them). Therefore it will always show up in the current OS language or current user selected language for MUI systems.
If my understanding is correct (and I strongly believe so), there is simply no way to localize that.

Edit (after comment from Jarek):

It seems that I was wrong. This page (scroll down to Internationalization) says:

The Eclipse SDK is designed as the basis for internationalized
products. The user interface elements provided by the Eclipse SDK
components, including dialogs and error messages, are externalized.
The English strings are provided as the default resource bundles.

That means it should be localizable. But it does not mean it is localized. Another quote:

German and Japanese locales are tested.

Does it mean it is localized into German and Japanese? I don't know. That was the case with Swing on Mac platform (I am not sure if it still remains the same).
However, that means that localization should be at least possible.

Edit 2 (current state of affairs)

I can't if it was the case in the first place (I don't think so), but nowadays all you have to do is to use language pack:

java -Duser.language=fr -Djava.library.path=C:\MyApp
-classpath C:\MyApp\swt.jar;C:\MyApp\swt-nl.jar;C:\MyApp\myApp.jar
my.org.HelloWorld

Just placing one or more language packs on your class path should be enough to have FileDialog translated. In case of Italian and few others it would be NLpack1. For Polish, Hungarian, Czech and Russian it would be NLpack2.

Original information just seems to be wrong, sorry (and thank you Jarek for your doubts, it should improve the quality of this answer).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文