【问题标题】:GWT i18n HTML filesGWT i18n HTML 文件
【发布时间】:2012-06-14 05:33:39
【问题描述】:

我已经为 java、UI Binder 提供了 GWT 的 i18n 功能,并尝试为 i18n 提供纯的、非托管在 java HTML 文件中。

阅读“Declarative Layout with UiBinder”后,我实现了一些代码,但没有成功:

<html xmlns:ui="urn:ui:com.google.gwt.uibinder">
<ui:with field='i18n' type='//.exampleConstants'/>
  <head>
   <title>Title of none-hosted HTML file and i18n part: <ui:text from='{i18n.title}'/></title>
 </head>
 <body>
  ...
 </body>
</html>

具有 id 的解决方案(在同一页面上描述:https://developers.google.com/web-toolkit/doc/latest/tutorial/i18n/)将由 RootPanel 提取,类似:

RootPanel.get("appTitle").add(new Label(constants.stockWatcher()));

也没有用,因为我的 HTML 文件没有与 Java 捆绑在一起。

如何在 HTML 文件中做 i18n?

【问题讨论】:

    标签: java html gwt


    【解决方案1】:

    好吧,这里有一个 Catch-22:HTML 文件无法知道在加载从 Java 代码编译出来的 JavaScript 之前使用哪个文本,这由页面,所以在它加载之后。

    您必须使用标准 Java Web 应用技术来国际化您的 HTML 页面,例如使其成为 JSP,并从 Accept-Languages 请求标头中检测首选语言。如果您这样做,则生成适当的&lt;meta name="gwt:property" content="locale=XX"&gt;,以便 GWT 应用程序引导程序(.nocache.js 文件)也不必猜测它,这可能导致 GWT 应用程序在与 HTML 不同的语言环境中运行生成的。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-01-23
    • 2012-04-09
    • 1970-01-01
    • 2013-05-24
    • 2011-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多