我将如何编码一个菜单,该菜单将允许用户选择一种语言,然后用户将使用自己选择的语言来呈现他的整个程序?
How would I go about coding a menu that will allow the user to select a language and thereafter the user will have his whole program rendered in the language of his choice?
注意:我正在使用Netbeans,建议使用自动内部化来制作bundle.properties文件的教程之一.
Note: I'm using Netbeans and one of the tutorials suggested using automatic internalization to make the bundle.properties files.
我不知道如何将语言设置为所选选项. 请详细解释,因为我几乎无法理解我现在在做什么.
What I don't know is how to set the language to selected option. Please explain in detail as I can barely understand what I'm doing right now.
int sel = cmbLang.getSelectedIndex(); switch (sel) { case 0: JOptionPane.showMessageDialog(null,"please make a selection"); break; case 1: fmt:setLocale(Locale.E);//set language to language 1 break; case 2: //set Language to language 2 break; }推荐答案
根据建议此处您可以使用Locale.setDefault(Locale yourDesiredLocale)(请参见 Javadoc )更改语言.
As suggested here you could use Locale.setDefault(Locale yourDesiredLocale)(see Javadoc) to change the language.
更多推荐
对菜单进行编码,该菜单允许用户选择一种语言
发布评论