zoukankan      html  css  js  c++  java
  • 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.
  • 相关阅读:
    Angular笔记
    Angular数据双向绑定机制
    块级元素垂直居中
    Linux文件系统硬/软连接
    Javascript 操作select控件大全(新增、修改、删除、选中、清空、判断存在等)
    Js获取当前日期时间及其它操作
    escape()、encodeURI()、encodeURIComponent()区别详解
    for (var i in obj/array){}
    setInterval中传递参数
    PHOTOSHOP常用快捷键大全
  • 原文地址:https://www.cnblogs.com/dbj66/p/9014427.html
Copyright © 2011-2022 走看看