Vaadin多语言Portlet组件标题 [英] Vaadin Multilanguage portlet component captions
问题描述
我正在Liferay Portal中使用Vaadin开发portlet,主要使用英文组件标题(名称),例如"Cancel","back","next"等.现在,我必须将portlet设置为多语言就绪",这意味着如果用户将其Liferay页面的语言设置为英语,那么他应该以英语查看我的portlet标题,但是如果用户将其Liferay页面的语言设置为德语,则portlet标题应以德语显示.
I'm developing portlets with Vaadin in a Liferay Portal , mostly with english component captions(names) like "Cancel" "back" "next" and so on. Now i have to make the portlets "Multilanguage ready" that means if an user has set the language of his Liferay page to english he should see my portlet captions in english , but if an user sets the language of his Liferay page to german, the portlet captions should be displayed in german.
有没有一种方法可以检查用户设置为他的主要语言的语言?
Is there a way to check wich language the user has set as his main Language ?
一个简单的例子:
John来自纽约,他的主要语言是英语,因此,一旦他登录帐户,Portlet组件标题的语言应以英语显示
John is from New York his main language is english so as soon as he logins to his account the language of the Portlet component captions should be displayed in english
Heinz来自柏林,他的主要语言是德语,因此,一旦他登录自己的帐户,Portlet组件标题的语言应以德语显示.
Heinz is from Berlin his main language is german so as soon as he logins to his account the language of the Portlet component captions should be displayed in german.
推荐答案
要从属性文件中获取标题,您可以尝试使用(假设在类之上)
For getting caption from your property files you can try with (assuming above class)
Button button = new Button() {
@Override
public void attach() {
ResourceBundle bundle = ResourceBundle.getBundle(Translation_portletApplication.class.getName(), user.getLocale());
setCaption(bundle.getString("first_name"));
}
};
window.addComponent(button);
要查看答案的完整内容,请参考此问题
To see full context of answer refer to this so question
这篇关于Vaadin多语言Portlet组件标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!