美文网首页
superset汉化

superset汉化

作者: Time一柒 | 来源:发表于2019-04-09 10:15 被阅读0次
    提取messages.pot文件(翻译模板):
    pybabel extract -F superset/translations/babel.cfg -k _ -k __ -k t -k tn -k tct -o superset/translations/messages.pot .
    
    更新messages.po文件:

    (语言的翻译对应文件)

    pybabel update -i superset/translations/messages.pot -d superset/translations/ -l zh
    
    翻译messages.po文件(!!!重体力活!!!)
    编译messages.po
    pybabel compile -d translations
    msgfmt superset/translations/zh/LC_MESSAGES/messages.po -o superset/translations/zh/LC_MESSAGES/messages.mo
    

    前端汉化:

    安装前端编译插件
    sudo apt-get install node-po2json
    
    编译前端翻译文本
    通过po文件生产json文件
    node-po2json -d superset -f jed1.x superset/translations/zh/LC_MESSAGES/messages.po superset/translations/zh/LC_MESSAGES/messages.json
    
    *原有的(有的资料推荐以此方法进行前端编译,可能是因为编译插件的问题我这里一直不能成功):
    npm install po2json -g
    po2json -d superset -f jed1.x superset/translations/zh/LC_MESSAGES/messages.po superset/translations/zh/LC_MESSAGES/messages.json
    
    前端翻译的标记:

    t() 例如

    t('Your query could not be saved')
    
    后端翻译的标记:

    括号前加下划线 _('') 例如

        list_title = _('List Databases')
        show_title = _('Show Database')
        add_title = _('Add Database')
        edit_title = _('Edit Database')
     label_columns = {'name':_('Name')}
    

    参考资料:
    https://imaidata.github.io/blog/2017/08/02/Superset%E6%B1%89%E5%8C%96/
    https://imaidata.github.io/blog/2017/09/04/superset%E6%B1%89%E5%8C%96(JS)/

    相关文章

      网友评论

          本文标题:superset汉化

          本文链接:https://www.haomeiwen.com/subject/cziviqtx.html