Skip to content

企业级应用的国际化解决方案(前端部分) #158

Open
@GuoYongfeng

Description

@GuoYongfeng

企业级应用的国际化解决方案

随着业务的对外发展,应用的国际化解决方案提上日程,本文仅限于应用前端开发部分的国际化方案讨论

需求及待解决问题

  • 整站资源的多语言编译:html/js/css/json
  • 数据传输的多语
  • 前端公共框架和插件的多语
  • 上下文context(后端负责)

参考示例

https://github.com/GuoYongfeng/i18n-webpack-demos

技术方案

i18next: internationalization ecosystem

基于i18next的国际化方案:http://i18next.com/docs/

webpack的i18n-webpack-plugin插件

示例代码

var path = require("path");
var I18nPlugin = require("i18n-webpack-plugin");
var languages = {
    "en": null,
    "de": require("./de.json")
};
module.exports = Object.keys(languages).map(function(language) {
    return {
        name: language,
        entry: "./example",
        output: {
            path: path.join(__dirname, "js"),
            filename: language + ".output.js"
        },
        plugins: [
            new I18nPlugin(
                languages[language]
            )
        ]
    };
});

更多信息:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions