baleeny
V2EX  ›  问与答

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

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

    text: "hello <b>world</b>"
    weixiangzhe
        3
    weixiangzhe  
       Mar 10, 2023
    看你现在用的是什么国,比如我最近的 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
        4
    baleeny  
    OP
       Mar 10, 2023
    @ColdBird 感谢
    baleeny
        5
    baleeny  
    OP
       Mar 10, 2023
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2984 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 58ms · UTC 14:21 · PVG 22:21 · LAX 07:21 · JFK 10:21
    ♥ Do have faith in what you're doing.