gpt4 book ai didi

java - GWT:如何为语言环境使用私有(private)标记

转载 作者:行者123 更新时间:2023-11-30 08:48:21 24 4
gpt4 key购买 nike

我正在使用 GWT i18n 制作一个网络应用程序。在这个应用程序中,我想设置一个自定义属性文件来支持与主要语言的差异。例如,我有一个 en_US 语言环境,但我也希望 en_US_x_custom 支持一些重新定义的属性字段(BCP 47 的规范说我可以使用 - x 标签用于私有(private)标签支持)。

让我展示一下我现在拥有的东西:

我有一个界面

public interface TestMsg extends Messages {
String value();
}

和一些属性文件:

  • TestMsg_en_US.properties
  • TestMsg_en_US_x_custom.properties

app.gwt.xml 中,我有这几行

<inherits name="com.google.gwt.i18n.I18N"/>
<inherits name="com.google.gwt.i18n.CldrLocales"/>
<extend-property name="locale" values="en_US"/>
<extend-property name="locale" values="en_US_x_custom"/>

但是,问题是编译失败并显示以下消息:

[ERROR] Type com.google.gwt.i18n.client.impl.LocaleInfoImpl_en_US_X-custom could not be referenced because it previously failed to compile with errors:
Tracing compile failure path for type 'com.google.gwt.i18n.client.impl.LocaleInfoImpl_en_US_X-custom'
[ERROR] Errors in 'generated://74EF808C0035420F02374EADB97661B8/com/google/gwt/i18n/client/impl/LocaleInfoImpl_en_US_X-custom.java'
[ERROR] Line 10: Syntax error on token "-", < expected
[ERROR] Line 17: The method getLocaleQueryParam() of type LocaleInfoImpl_en_US_X must override or implement a supertype method
[ERROR] Line 10: The public type LocaleInfoImpl_en_US_X must be defined in its own file
[ERROR] Line 22: The method getDateTimeFormatInfo() of type LocaleInfoImpl_en_US_X must override or implement a supertype method
[ERROR] Line 10: Syntax error, insert "AdditionalBoundList1" to complete TypeParameter1
[ERROR] Line 27: The method getNumberConstants() of type LocaleInfoImpl_en_US_X must override or implement a supertype method
[ERROR] Line 12: The method getLocaleName() of type LocaleInfoImpl_en_US_X must override or implement a supertype method
[ERROR] Errors in 'com/google/gwt/i18n/client/LocaleInfo.java'
[ERROR] Line 37: Rebind result 'com.google.gwt.i18n.client.impl.LocaleInfoImpl_en_US_X-custom' could not be found

如何摆脱这个编译错误?我该如何解决这个问题?

最佳答案

您可以省略区域设置的 -x 部分。然后您可以将区域设置指定为 en_US_custom 并将属性文件命名为 TestMsg_en_US_CUSTOM.properties(注意大写字母)。

关于java - GWT:如何为语言环境使用私有(private)标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32012971/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com