JFace对话框按钮翻译 [英] JFace dialog button translation

查看:170
本文介绍了JFace对话框按钮翻译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个独立的SWT / JFace应用程序。

I am creating a standalone SWT/JFace application.

我以前使用普通的旧SWT MessageBox:

I used to use plain old SWT MessageBox:

int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
MessageBox messageBox = new MessageBox (getShell(), style);
messageBox.setText ("Question");
messageBox.setMessage ("So?");
boolean result = messageBox.open() == SWT.YES;

我尝试切换到JFace MessageDialog

I try to switch to JFace MessageDialog

boolean result = MessageDialog.openQuestion(getShell(), "Question", "So?");

我遇到的问题是在SWT中,Yes和No按钮标签是用我的语言翻译的,而在JFace则并非如此。有什么想法?

The problem I have is that in SWT, the Yes and No button labels are translated in my language, while in JFace it is not the case. Any idea?

我引用的jar是swt 3.8.0,jface 3.8.0和jface dependencies core.commands 3.6.1和equinox.common 3.6.100。

My referenced jars are swt 3.8.0, jface 3.8.0, and jface dependencies core.commands 3.6.1 and equinox.common 3.6.100.

推荐答案

在SWT的MessageBox类中,标签由OS设置。对于JFace,您必须提供自己的翻译文件。您可以在此处获取一种语言版本。当然,您也可以自己提供。此链接说明了如何使用资源包进行翻译。您可以在org / eclipse / jface / messages.properties下找到原始翻译文件。您必须将自己的翻译文件(messages_ [语言代码] .properties)添加到项目中的同一包路径中。请注意,资源包与OSGi包没有任何共同之处。

In the MessageBox class of SWT the labels are set by the OS. For JFace you have to provide your own translation file. You can get one for your language here. Of course you can also provide it on your own. This link explains how to use resource bundles for translation. You find the original translation file under org/eclipse/jface/messages.properties . You have to add your own translation file (messages_[language code].properties) to the same package path in your project. Note that resource bundles have nothing in common with OSGi bundles.

这篇关于JFace对话框按钮翻译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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