How to make client side I18n with mustache.js

后端 未结 5 1652
北荒
北荒 2021-02-08 21:11

i have some static html files and want to change the static text inside with client side modification through mustache.js.

it seems that this was possible Twitter\'s mu

5条回答
  •  庸人自扰
    2021-02-08 21:39

    You can use lambdas along with some library like i18next or something else.

    {{#i18n}}greeting{{/i18n}} {{name}}
    

    And the data passed:

    {
        name: 'Mike',
        i18n: function() {
            return function(text, render) {
                return render(i18n.t(text));
            };
        }
    }
    

    This solved the problem for me

提交回复
热议问题