【问题标题】:how to do i18n while using react-templates使用 react-templates 时如何做 i18n
【发布时间】:2016-09-16 01:38:36
【问题描述】:

react-templates 是一个很好的分离模板和逻辑代码的解决方案,但是,如果我有多个模板但引用一个逻辑代码,比如 i18n 请求。 例如。

post.js //which is the logic code
post.en.rt //which is the template for english
post.es.rt //for spanish

如何在 post.js 中加载?

PS:我不想在 post.js 中加载所有语言模板,那将是一个大文件,对网络来说是一种浪费

【问题讨论】:

    标签: reactjs webpack react-templates


    【解决方案1】:

    最后,我使用带有正则表达式的捆绑加载器来解决我的问题。

    这样的代码

    { 
        test: /(en|cn)\.rt$/, 
        loaders: [
                "bundle?regExp=(en|cn)\.rt$&name=[1]",
                "react-templates-loader"
            ]
    },
    

    那么所有的 xxx.en.rt 文件都会打包成一个 en.js

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-07
      • 2011-12-24
      • 1970-01-01
      • 2019-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-16
      相关资源
      最近更新 更多