简体   繁体   English

Java:如何强制对swt FileDialog进行本地化

[英]Java: How to force the localization for swt FileDialog

I would localize a FileDialog component in English. 我将用英语本地化FileDialog组件。 My default language is Italian. 我的默认语言是意大利语。 Is it possible? 可能吗?

The project where I'm using the FileDialog is an Eclipse plug-in project. 我使用FileDialog的项目是Eclipse插件项目。

I've found the solution only for JFileChooser components and it works. 我发现该解决方案仅适用于JFileChooser组件,并且可以正常工作。

Thank you in advance. 先感谢您。

The information in original answer is outdated. 原始答案中的信息已过时。 Please scroll down to Edit 2. 请向下滚动到“编辑2”。

My understanding is that SWT is calling some Operating System API to display common dialogs (FileDialog be one of them). 我的理解是SWT正在调用某些操作系统API来显示常见对话框(FileDialog就是其中之一)。 Therefore it will always show up in the current OS language or current user selected language for MUI systems. 因此,它将始终以当前的OS语言或MUI系统的当前用户选择的语言显示。
If my understanding is correct (and I strongly believe so), there is simply no way to localize that. 如果我的理解是正确的(我坚信是这样),那么根本就没有办法将其本地化。

Edit (after comment from Jarek): 编辑(来自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. Eclipse SDK被设计为国际化产品的基础。 The user interface elements provided by the Eclipse SDK components, including dialogs and error messages, are externalized. Eclipse SDK组件提供的用户界面元素(包括对话框和错误消息)已外部化。 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). Mac平台上的Swing就是这种情况(我不确定它是否仍然保持不变)。
However, that means that localization should be at least possible. 但是,这意味着本地化至少应该可行。

Edit 2 (current state of affairs) 编辑2(当前状态)

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 : 我不能一开始就是这种情况(我不这么认为),但是如今您要做的就是使用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 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. 只需在类路径上放置一种或多种语言包就足以翻译FileDialog。 In case of Italian and few others it would be NLpack1 . 如果使用的是意大利语, 则为NLpack1 For Polish, Hungarian, Czech and Russian it would be NLpack2 . 对于波兰语,匈牙利语,捷克语和俄语,它将是NLpack2

Original information just seems to be wrong, sorry (and thank you Jarek for your doubts, it should improve the quality of this answer). 抱歉,原始信息似乎是错误的(并且感谢Jarek的疑问,它应该可以改善此答案的质量)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM