.properties 存储长文本值/列表/其他

发布于 2024-12-29 11:52:33 字数 1646 浏览 0 评论 0原文

我正在使网站国际化,但我似乎找不到一种方法来存储包含其他标签的大段落。

例如,假设我有这个:(调用此示例 1

<h1> the title </h1>
<p> 
    ... A very large paragraph ... <h:link value="click me" outocme="newPage"/> ... more text...
</p>

或者类似的内容:(调用此示例 2

<h1> check this list out </h1>
<ul>
    <li> ... text here </li>
    <li> ... text here </li>
    <!-- more items -->
</ul>

我使用 JSF 2.0 并使用捆绑的国际化我的页面的资源,效果很好,因为有很多示例如何做到这一点。

但我希望能够做的就是示例1(msg是链接到我的包的变量)

<h1> #{msg['page.title']} </h1>
<p> #{msg['page.largeParagraph']} </p>

示例2 em> 看起来像这样:

<h1> #{msg['page2.title']} </h1>
<ul>
    #{msg['page2.myList']}
</ul>

有什么办法可以做到这一点,或者我必须求助于这样的东西(使用示例1

<h1> #{msg['page.title']} </h1>
<p> 
    #{msg['page.largeParagraph.part1']} <h:link value="#{msg['page.largeParagraph.link']} #{msg['page.largeParagraph.part2']}
</p>

示例2也是如此> 我需要为每个不同的条目

  • 当我们做此类事情时,最佳实践是什么?

    感谢您的任何意见。

    编辑:

    我想到默认情况下会转义字符。因此我尝试过:

    <p><h:outputText value="#{msg['page.paragraphWithLink']}" escape="false"/></p>
    

    不幸的是,这对我不起作用。

    编辑2:

    使用escape="false"确实适用于,但绝对不适用于

    I am in the process of internationalising a website and I can't seem to find a way to store large paragraphs that my contain some other tags.

    For example let's say I have this : (call this example 1)

    <h1> the title </h1>
    <p> 
        ... A very large paragraph ... <h:link value="click me" outocme="newPage"/> ... more text...
    </p>
    

    Or again something of this sort : (call this example 2)

    <h1> check this list out </h1>
    <ul>
        <li> ... text here </li>
        <li> ... text here </li>
        <!-- more items -->
    </ul>
    

    I am in JSF 2.0 and using the bundeled resource to internationalise my page and that's working fine as there are many examples how to do this.

    But what I'd like to be able to do is something like this for example 1 (msg being my variable linked to my bundle)

    <h1> #{msg['page.title']} </h1>
    <p> #{msg['page.largeParagraph']} </p>
    

    And example 2 would look like this :

    <h1> #{msg['page2.title']} </h1>
    <ul>
        #{msg['page2.myList']}
    </ul>
    

    Is there any way to do that, or do I have to resort to something like this (using example 1)

    <h1> #{msg['page.title']} </h1>
    <p> 
        #{msg['page.largeParagraph.part1']} <h:link value="#{msg['page.largeParagraph.link']} #{msg['page.largeParagraph.part2']}
    </p>
    

    The same would be for example 2 where I would need a different entry for each <li>.

    What is the best practice when we are doing something of this sort?

    Thank you for any input.

    Edit :

    It had occured to me that by default did escape characters. Therefore I have tried :

    <p><h:outputText value="#{msg['page.paragraphWithLink']}" escape="false"/></p>
    

    Unfortunately, this did not work for me.

    Edit 2 :

    Using escape="false" did work for <strong> but definetly does not work for <h:link>.

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

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

    发布评论

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

    评论(1

    一城柳絮吹成雪 2025-01-05 11:52:33

    您不能在捆绑文件中指定 JSF 组件。它们不会被解析为组件树的一部分。 Web 浏览器也不理解 JSF 标签,它只理解 HTML。纯 HTML 应该可以与 配合使用。

    page.paragraphWithLink=lorem ipsum <a href="newPage.xhtml">click me</a> dolor sit amet
    

    You cannot specify JSF components in the bundle file. They won't be parsed as part of the component tree. The webbrowser also doesn't understand JSF tags, it only understands HTML. Just plain HTML should work with <h:outputText escape="false">.

    page.paragraphWithLink=lorem ipsum <a href="newPage.xhtml">click me</a> dolor sit amet
    
    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文