Durandal (knockout) app with multilanguage support

后端 未结 4 1177
自闭症患者
自闭症患者 2021-02-01 08:18

I am building multilingual support for the app I\'m working on. After doing some research and reading SO (internationalization best practice) I am trying to integrate that in a

4条回答
  •  隐瞒了意图╮
    2021-02-01 08:37

    Here is an example repo made using i18next, Knockout.Punches, and Knockout 3 with Durandal:

    https://github.com/bestguy/knockout3-durandal-i18n

    This allows for Handlebars/Angular-style embeds of localized text via an i18n text filter backed by i18next:

    {{ 'home.label' | i18n }}

    also supports attribute embeds:

    {{ 'home.label' | i18n }}

    And also lets you pass parameters:

    {{ 'home.welcome' | i18n:name }}

    JSON example:

    English (en):

    {
      "home": {
        "label": "Home Page",
        "title": "Type your name…"
        "welcome": "Hello {{0}}!",
      }
    }
    

    Chinese (zh):

    {
      "home": {
        "label": "家",
        "title": "输入你的名字……",
        "welcome": "{{0}}您好!",
      }
    }
    

提交回复
热议问题