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.
  • 相关阅读:
    sqlite数据库的char,varchar,text,nchar,nvarchar,ntext的区别(转)
    DELPHI XE5-8 弹出列表框供选择
    delphi弹出选择对话框选择目录|SelectDirectory 函数(转)
    php 与java安卓客户端的查询交互
    sql查询语句的拼接小技巧(高手勿喷)
    高德地图应用——与云图后台交互
    Inno Setup 通用脚本及简要说明( 一般情况够用了)
    不用SQL给打印记录编号
    DELPHI XE5/6/7 android 无线真机调试
    超级简单的例子说明JAVA PACKET CLASS 和变量之间的关系
  • 原文地址:https://www.cnblogs.com/dbj66/p/9014427.html
Copyright © 2011-2022 走看看