baleeny
V2EX  ›  问与答

问一下前端 i18n 国际化的一个问题

  •  
  •   baleeny · Mar 10, 2023 · 2005 views
    This topic created in 1335 days ago, the information mentioned may be changed or developed.
    一段文本的个别文字加粗或者颜色不同,或者换行,i18n 怎么处理的,将这一段文字拆分成不同段?
    5 replies  •  2023-03-10 16:44:14 +08:00
    ColdBird
    ColdBird
    Mar 10, 2023
    1
    i18next 支持插入标签(关键字:Trans ),文本内需要特殊处理的部分使用标签进行管理即可
    acthtml
    acthtml
    Mar 10, 2023
    2
    我不拆开,直接支持特殊字符。

    text: "hello <b>world</b>"
    weixiangzhe
    weixiangzhe
    Mar 10, 2023
    3
    看你现在用的是什么国,比如我最近的 vue-i18n 你说的这个场景他是支持的

    写法

    ```vue
    <i18n-t
    keypath="数字{n1},数字{n2},数字{n3}"
    tag="div"
    pl-8px
    pr-8px
    >
    <template #n1>
    22
    </template>
    <template #n2>
    3
    </template>
    <template #n3>
    <span text-bold>666</span>
    </template>
    </i18n-t>
    ```
    baleeny
    baleeny
    OP
    Mar 10, 2023
    4
    @ColdBird 感谢
    baleeny
    baleeny
    OP
    Mar 10, 2023
    5
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3050 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 04:41 · PVG 12:41 · LAX 20:41 · JFK 23:41
    ♥ Do have faith in what you're doing.