Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在GWT中支持i18n_Java_Gwt - Fatal编程技术网

Java 在GWT中支持i18n

Java 在GWT中支持i18n,java,gwt,Java,Gwt,到目前为止,我们的web应用程序只支持英语。现在我们也必须为意大利人提供支持。有些功能有GWT模块。为了支持意大利语,我在文件“APP_Module.gwt.xml的下面一行中添加了 我还将“XXX_it.properties”文件放在源代码下,用于保存en的属性文件 通过以下行设置jsp中的区域设置: <meta name="gwt:property" content="locale=${locale}"> 现在,问题是如何编译代码。我正在调试该应用程序,但它没有触及WE

到目前为止,我们的web应用程序只支持英语。现在我们也必须为意大利人提供支持。有些功能有GWT模块。为了支持意大利语,我在文件“APP_Module.gwt.xml的下面一行中添加了


我还将“XXX_it.properties”文件放在源代码下,用于保存en的属性文件

通过以下行设置jsp中的区域设置:

<meta name="gwt:property" content="locale=${locale}">

现在,问题是如何编译代码。我正在调试该应用程序,但它没有触及WEB-INF/src下提供的GWT的客户机代码


我对GWT很陌生。请建议如何编译代码,否则不需要编译。它将自动接受“APP_Module.gwt.xml”中所做的更改,还有一些其他问题。如何查看GWT日志?

要查看GWT日志,您可以使用gradlew GWT,也可以使用它来编译代码。

要向GWT应用程序添加对区域设置的支持,您需要在xxx.GWT.xml中执行以下操作:

下添加以下内容以包括支持:

<inherits name="com.google.gwt.i18n.I18N" />
然后您需要告诉GWT将它们编译成类。这是pom.xml文件中的示例(如果不使用maven,则必须使用不同的方法,但仍需要对其进行配置)


org.codehaus.mojo
GWTMaven插件
1.3.1.谷歌
i18n
生成同步
编译
foo.bar.client.i18n.MyMessages

然后需要重新编译代码。在maven
mvn编译中
。所有这些,您都可以在“生成的源”文件夹中随时使用您的邮件。

大部分信息都可以在这里找到:谢谢@sm4,工作正常。但是现在发生的是像ù,ì这样的字符没有正确显示。有没有设置编码的地方?这很可能是因为您直接将UTF-8(或任何其他编码)放入.properties。这些文件必须采用ISO-8859-1编码。尝试使用这个问题中的插件:正确的方法是对属性中的所有特殊字符进行转义,这个插件将为您执行此操作。当然,托管脚本的jsp页面可以这样定义编码:
我正在使用blow-line GWT.create(propertiesFile.class)在GWT中加载属性文件;知道用哪种编码读取属性文件吗?
<inherits name="com.google.gwt.i18n.I18N" />
<extend-property name="locale" values="en,it"/>
<set-property-fallback name="locale" value="en"/>
src/main/resources/foo/bar/client/i18n/MyMessages.properties
src/main/resources/foo/bar/client/i18n/MyMessages_it.properties
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <version>1.3.1.google</version>
            <executions>
                <execution>
                    <goals>
                        <goal>i18n</goal>
                        <goal>generateAsync</goal>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <i18nMessagesBundles>
                    <resourceBundle>foo.bar.client.i18n.MyMessages</resourceBundle>
                </i18nMessagesBundles>
            </configuration>
        </plugin>