Localization and globalization file translate tool client side - javascript

江枫思渺然 提交于 2019-12-11 17:03:22

问题


I'm a member of a team with more than 20 developers. Each developer works on a separate module. In each module, We load data only for the desired language. For this purpose we save data to a separate files for each language.

Example Module 1:

locale (root folder)

    en
        en.js
    pt
        pt.js
    fr 
        fr.js

en.js is,

define(function() { 

    var label = {
        "name" : "Name",
        "age" : "Age",
        "location" : "Location"
    }

    var message = {
        "save": "data saved",
        "update": "data updated"
    }

   return {
        label: label,
        message: message
    };

});

I will use this obj in my module wherever applicable, like fileName.label.name that will print "Name" in desired place.

like that if a user change the language from english to french(fr) I will get the data from fr.js, which looks like something below:

var label = {
        "name" : "****",  [*** - something in french]
        "age" : "***",
        "location" : "***"
    }

so fileName.label.name will print the french text.

Here, I'm struck with converting/translating those en file to french and other languages.

I would like to know is there a tool which can translate files and generate desired language , and there will be N number of modules if there's a generalized way to translate would be grateful like give a path of locale files and the tool will give the dedsired op.

来源:https://stackoverflow.com/questions/53864279/localization-and-globalization-file-translate-tool-client-side-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!