• superset深度汉化


    简单汉化

    1、编辑/usr/python-3.6.4/lib/python3.6/site-packages/superset目录下的config.py

    Babel config for translations处更改为:

    # ---------------------------------------------------

    # Babel config for translations

    # ---------------------------------------------------

    # Setup default language

    BABEL_DEFAULT_LOCALE = 'zh'

    # Your application default translation path

    BABEL_DEFAULT_FOLDER = 'babel/translations'

    # The allowed translation for you app

    LANGUAGES = {

        'en': {'flag': 'us', 'name': 'English'},

        'it': {'flag': 'it', 'name': 'Italian'},

        'fr': {'flag': 'fr', 'name': 'French'},

        'zh': {'flag': 'cn', 'name': 'Chinese'},

    }

    1.2下载superset语言文件

    https://github.com/AmberCa/incubator-superset/blob/master/superset/translations/zh/LC_MESSAGES/messages.po

    下载完成后,将文件放在下面的目录下

    /usr/python-3.6.4/lib/python3.6/site-packages/flask_appbuilder/translations/zh/LC_MESSAGES/messages.po

    1.3编译messages.po文件

    pybabel compile -d /usr/python-3.6.4/lib/python3.6/site-packages/flask_appbuilder/translations

    1.4重启superset,简单汉化完成。

    2深度汉化

    1. Go to top directory of superset directory.
      (venv) [root@centos4 site-packages]# pwd
      /root/Dev/Superset/venv/lib/python2.7/site-packages
    2. Modify babel.cfg to add static for js/jsx path, OTHERWISE "fabmanager babel-extract" will NOT extract the messages for translation in js/jsx files.

    A big question, why there is NO static in the github repo?
    Without the static in https://github.com/apache/incubator-superset/blob/master/superset/translations/babel.cfg, how could the messages in js/jsx be extracted?
    Could you please help answer?

    (venv) [root@centos4 translations]# cat babel.cfg
    [ignore: superset/assets/node_modules/**]
    [python: superset/**.py]
    [jinja2: superset/**/templates/**.html]
    [javascript: superset/static/assets/javascripts/**.js]
    [javascript: superset/static/assets/javascripts/**.jsx]
    [javascript: superset/static/assets/visualizations/**.js]
    [javascript: superset/static/assets/visualizations/**.jsx]
    encoding = utf-8

      1. Extract the messages marked for translation
        (venv) [root@centos4 site-packages]# fabmanager babel-extract --target superset/translations/ --output superset/translations/messages.pot --config superset/translations/babel.cfg -k _ -k __ -k t -k tn -k tct
      2. Compile and generate json file.
        (venv) [root@centos4 site-packages]# fabmanager babel-compile --target superset/translations/
      3. install   cnpm install po2json -g
      4. (venv) [root@centos4 site-packages]# /opt/node-v8.11.1-linux-x64/bin/po2json -d superset -f jed1.x superset/translations/zh/LC_MESSAGES/messages.po superset/translations/zh/LC_MESSAGES/messages.json
        (venv) [root@centos4 site-packages]# po2json -d superset -f jed1.x superset/translations/zh/LC_MESSAGES/messages.po
      5. Restart Superset and select Chinese locale.
  • 相关阅读:
    WBS概念
    Cognos 8体系结构:请求流程
    Cognos8.4安装配置指南
    Cognos 8体系结构:层级结构
    程序猿媛都偷偷深爱的九大习惯
    Cookie是存储在客户端上的一小段数据
    Web前端必须规避的8个误区
    WEB前端开发常用的优化技巧汇总
    微信小程序怎么开发(小程序开发文档)
    入门 IT 行业,该具备哪些技能?
  • 原文地址:https://www.cnblogs.com/dbj66/p/9014427.html
Copyright © 2020-2023  润新知