目前,Im公司正在从事较大的 Java台式应用工作,现在正在准备增加翻译。 我对18岁制度的看法是,它没有提供任何形式的编辑时间检查。
在java s系统中,你拥有像HashMap
这样的东西,每个地方化的座标都有“Key”,而翻译的座标当时是“Value”。 参见:http://docs.oracle.com/javase/tutorial/i18n/intro/ subsequently.html。
Locale currentLocale;
ResourceBundle messages;
currentLocale = new Locale(language, country);
messages = ResourceBundle.getBundle("MessagesBundle", currentLocale);
System.out.println(messages.getString("greetings"));
如果您申请简单/小小,这便行不通。 但是,在大量应用中,有数千处翻译,因此,你可能会在“灰色”中打上打字,从而得到空洞或错误的扼杀。
With a little luck, the application throws a RuntimeException
to tell you about it, but even then it is possible that you don t even come to this point because the wrong "Key" is used in a dialog that might not show up under certain circumstances (say it s an error dialog).
为防止这种情况发生,采用一种系统,对旧的“灰色”进行实时检查,将是一个更好的想法。 例如,在安伯,你在一份XML-书上具体说明了资源,然后将其编入索引,并绘制成一个类别(包括“关键”使用)。 这样,你们就获得这样的东西(从http://developer.android.com/guide/topics/resources/accessing-resources.html>Android Docs):
// Set the text on a TextView object using a resource ID
TextView msgTextView = (TextView) findViewById(R.id.msg);
msgTextView.setText(R.string.hello_message);
如果你在“钥匙”中有一个字体,那么你在汇编时就会出现错误(你也从民主选举学会那里获得了“独一无二的”。
现在,为了像这项工作一样做一些事情,你需要很少的工具/文字,而这种工具/文字却能够把一部分指数化并产生资源类别(R.java
)。 在安伯,Eclipse-plugin(或您的一般发展研究所)对你来说就是这样。
我现在的问题是:是否有我能够用于 Java正常桌面应用的系统? 或者,我说什么是令人可怕的错吗?