使用 Tapestry-3 将 I18n 文本注入 javascript

发布于 2024-07-27 20:45:31 字数 694 浏览 3 评论 0原文

我正在将国际化添加到 Tapestry 应用程序中。

是否有标准的 Tapestry-3 技术来国际化显示为 Javascript 文字的字符串?

例如:

<input jwcid="submitBtn" type="submit" accesskey="U" value="Update" class="actionBtn" onclick="return confirm('Are you sure that you want to do that?');"/></td>

我可以简单地将问题替换为在此上下文和任何其他上下文中的挂毯标签吗? 可以这么说:

<input jwcid="submitBtn" type="submit" accesskey="U" value="Update" class="actionBtn" onclick="return confirm('<span key="AreYouSure">Are you sure that you want to do that?</span>');"/></td>

这意味着源文件在属性中包含一个元素,该元素在 JSP 中就可以了。 Tapestry-3 可以处理这个问题吗? 如果没有,有没有办法在 Tapestry-3 中做到这一点?

I'm adding Internationalization to a tapestry app.

Is there a standard tapestry-3 technique to Internationalize strings that appear as Javascript literals?

For example:

<input jwcid="submitBtn" type="submit" accesskey="U" value="Update" class="actionBtn" onclick="return confirm('Are you sure that you want to do that?');"/></td>

Can I simply replace the question with a tapestry tag in this and any other context? Say something like:

<input jwcid="submitBtn" type="submit" accesskey="U" value="Update" class="actionBtn" onclick="return confirm('<span key="AreYouSure">Are you sure that you want to do that?</span>');"/></td>

This means that the source file contains an element inside an attribute which would be fine inside a JSP. Does tapestry-3 handle this? If not, is there a way to do this in tapestry-3?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我早已燃尽 2024-08-03 20:45:31

这在 T3 中也可以正常工作 - 另一个选择是在页面顶部初始化 i18n js 字符串:

<script>
  var jsStrings = { 
    sure : '<span key="AreYouSure"/>',
    ...
  };
</script>

然后使用它们:

<input jwcid="submitBtn" onclick="return confirm(jsStrings.sure);"/>

This works fine in T3 as well - another option is to initialize your i18n js strings at the top of the page:

<script>
  var jsStrings = { 
    sure : '<span key="AreYouSure"/>',
    ...
  };
</script>

and then just use them:

<input jwcid="submitBtn" onclick="return confirm(jsStrings.sure);"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文