问题描述
我使用 i18n 国际化开发了一个 GWT 应用程序.在主机/开发模式下它工作正常,但启动 GWT 编译会出现此错误:找不到密钥 xxx 的资源,如下所示.
I've developed a GWT app using i18n internationalization. In Host/Dev mode it works fine, but launching GWT compile gives this error: No resource found for key xxx, like below.
Compiling module ...rte.RTE
Scanning for additional dependencies: file:/home/.../client/i18n/RTEValidationMessages.java
Computing all possible rebind results for '...client.i18n.RTEMessages'
Rebinding ...client.i18n.RTEMessages
Invoking com.google.gwt.dev.javac.StandardGeneratorContext@e7dfd0
Processing interface ...client.i18n.RTEMessages
Generating method body for txtIndirizzo3()
[ERROR] No resource found for key 'txtIndirizzo3'
消息加载后绑定.
public class RTEValidationMessages {
private RTEMessages additionalMessages;
public RTEValidationMessages() {
additionalMessages = GWT.create(RTEMessages.class);
}
}
删除给出错误的方法,会导致另一个随机方法出错,而不是接口...client.i18n.RTEMessages 之前或之后的方法.
Deleting the method which gives the error, results in another random method with error, say not the method before or after in the interface ...client.i18n.RTEMessages.
非常感谢帮助.
推荐答案
我在使用国际化时遇到过类似的错误.我有英语和波兰语的属性文件:labels_en.properties
和 labels_pl.properties
.解决方案是创建一个文件 labels.properties
(在我的例子中它只是一个 labels_en.properties
的副本).这很奇怪,但不知何故它有所帮助.
I had a similar error once when using internationalization. I had properties files for English and Polish languages: labels_en.properties
and labels_pl.properties
. The solution was to create also a file labels.properties
(in my case it was just a copy of labels_en.properties
). It is weird but somehow it helped.
您还应该将属性文件与 RTEMessages
类放在同一个包中.
You should also keep your properties files in the same package as your RTEMessages
class.
这篇关于GWT 2.X 找不到密钥的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!