为 JSF / ICEfaces 设置浮点格式化区域设置?

发布于 2024-08-11 06:17:30 字数 198 浏览 2 评论 0原文

我正在编写一个 JSF (ICEfaces) 应用程序,使用资源包来处理国际化。

该应用程序很好地为资源包应用了(默认)荷兰语“nl”区域设置,但无法在格式化浮点数时应用相同的区域设置,即使我使用

如何使浮点数遵循当前区域设置?

I am writing a JSF (ICEfaces) application using resource bundles to handle internationalisation.

The application nicely applies the (default) Dutch "nl" locale for the resource bundle but fails to apply the same locale on formatting floating point numbers, even if I explicitly set the locale for a page using <f:view locale="nl">.

How do I make floating point numbers follow the current locale setting?

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

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

发布评论

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

评论(2

萝莉病 2024-08-18 06:17:31

您可能没有使用格式<的转换器/a> 将数字添加到适当的区域设置。

  <f:view locale="nl">
    <h:outputText value="#{numbers.someDouble}">
      <f:convertNumber pattern="#,##0.00;(#,##0.00)" />
    </h:outputText>
    <br />
    <h:outputText value="#{numbers.someDouble}">
      <f:convertNumber locale="en" pattern="#,##0.00;(#,##0.00)" />
    </h:outputText>
  </f:view>

此视图(带有数字的荷兰语区域设置视图,后跟英语区域设置编号)产生以下输出:

12.341.234,43
12,341,234.43

It is likely that you are not using a converter to format the numbers to the appropriate locale.

  <f:view locale="nl">
    <h:outputText value="#{numbers.someDouble}">
      <f:convertNumber pattern="#,##0.00;(#,##0.00)" />
    </h:outputText>
    <br />
    <h:outputText value="#{numbers.someDouble}">
      <f:convertNumber locale="en" pattern="#,##0.00;(#,##0.00)" />
    </h:outputText>
  </f:view>

This view (a Dutch locale view with a number, followed by an English locale number) produces the following output:

12.341.234,43
12,341,234.43
未蓝澄海的烟 2024-08-18 06:17:31

您可以使用嵌套 标记并将默认区域设置设置为 faces.config.xml 中的“nl”。
这样,转换器会自动获取并使用默认区域设置,并且您无需在每个 标记处指定模式。

faces-config.xml:

    <application>
        <locale-config>
          <default-locale>nl</default-locale>
        </locale-config>
    </application>

You can use nest <convertNumber> tag and set the default locale to "nl" in faces.config.xml.
That way, the converters automatically get and use the default locale and you do not need to specify a pattern at each <convertNumber> tag.

faces-config.xml:

    <application>
        <locale-config>
          <default-locale>nl</default-locale>
        </locale-config>
    </application>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文