如何在Java / Swing应用程序中实现多语言? [英] How to implement multilanguage in Java/Swing applications?

查看:200
本文介绍了如何在Java / Swing应用程序中实现多语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Swing应用程序中实现多语言支持的不同方法有哪些?

What are the different ways of implementing multilingual support in Swing applications?

您是否将ResourceBundle与属性文件一起使用并在每个帧中实现?它对你有用吗?如果您使用某种GUI编辑器怎么办?还有其他方法吗?

Are you using ResourceBundle with property file and implementing it in every frame? Does it work good for you? What if you use some kind of GUI editor? Is there any other way around?

在工作中我们使用Matisse4MyEclipse并且每次保存屏幕时都会重新生成代码,因此只使用Externalize Strings在这里不起作用。一种方法是将其定义为每个组件的自定义属性,这非常烦人。另一种方法是在matisse生成的代码之后再次检查多语言组件及其属性,这也是一种痛苦。

At work we are using Matisse4MyEclipse and the code gets regenerated every time we save the screen, so simply using Externalize Strings won't work here. One way is to define it as custom property for each component, which is very annoying. Another way is to go over the multilanguage components and their properties again after matisse's generated code, which is a pain, too.

推荐答案

好吧,你必须使用 ResourceBundle s。但是,如果您要设置componet text属性而不是人类可读文本 RB.getString()的文本。然后,如果马蒂斯重新生成形式,捆绑密钥将保留,本地化将起作用。示例:

Well, you had to use ResourceBundles. But if you are setting the componet text property use instead of human readable text the text for RB.getString(). Then if the Matisse regenerates form the bundle key will stay and localization will work. Example:

我将使用Matisse页面中的此图像:

插图http://www.myeclipseide.com/documentation/quickstarts/m4m_overview/images/properties_view1.gif

I will use this image from Matisse pages:
Illustration http://www.myeclipseide.com/documentation/quickstarts/m4m_overview/images/properties_view1.gif.

您可以看到属性文字。有价值我的新标签。而不是这个你可以使用 rb.getString(myNewLabel.my.message)其中 rb 的ResourceBundle 。唯一的问题应该是太聪明的属性编辑器对你不利。我从不使用任何所见即所得的编辑器(个人喜好,我总是手工制作UI设计)。

there you can see the the property text. There is value "My New Label". Instead of this you can use rb.getString("myNewLabel.my.message") where rb is ResourceBundle. The only problem should be too intelligent properties editor going against you. I never work with any wysiwyg editor (personal preference, I do always UI design by hand).

这篇关于如何在Java / Swing应用程序中实现多语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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