Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

complete chinese translation #517

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 21 additions & 4 deletions caravel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from flask.ext.appbuilder.baseviews import expose
from flask.ext.cache import Cache
from flask.ext.migrate import Migrate

from flask.json import JSONEncoder
from caravel import version

VERSION = version.VERSION_STRING
Expand All @@ -24,9 +24,9 @@
app = Flask(__name__)
app.config.from_object(CONFIG_MODULE)
if not app.debug:
# In production mode, add log handler to sys.stderr.
app.logger.addHandler(logging.StreamHandler())
app.logger.setLevel(logging.INFO)
# In production mode, add log handler to sys.stderr.
app.logger.addHandler(logging.StreamHandler())
app.logger.setLevel(logging.INFO)

db = SQLA(app)

Expand All @@ -47,11 +47,28 @@
logging.getLogger().addHandler(handler)


class CustomJSONEncoder(JSONEncoder):
"""This class adds support for lazy translation texts to Flask's
JSON encoder. This is necessary when flashing translated texts."""

def default(self, obj):
from speaklater import is_lazy_string
if is_lazy_string(obj):
try:
return unicode(obj) # python 2
except NameError:
return str(obj) # python 3
return super(CustomJSONEncoder, self).default(obj)


class MyIndexView(IndexView):
@expose('/')
def index(self):
return redirect('/caravel/welcome')


#app.json_encoder = CustomJSONEncoder

appbuilder = AppBuilder(
app, db.session,
base_template='caravel/base.html',
Expand Down
8 changes: 4 additions & 4 deletions caravel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# ---------------------------------------------------------

# Your App secret key
SECRET_KEY = '\2\1thisismyscretkey\1\2\e\y\y\h' # noqa
SECRET_KEY = 'FWGVwZRAfFNyjt0hNViNRJ6heBkHqWIwboI0fYgtsGorkiRQhaB3fXuoBKcz4ebA' # noqa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, you may want to rotate that


# The SQLAlchemy connection string.
SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/caravel.db'
Expand Down Expand Up @@ -60,7 +60,7 @@
# tz.tzlocal() : Using local timezone
# other tz can be overridden by providing a local_config
DRUID_IS_ACTIVE = True
DRUID_TZ = tz.tzutc()
DRUID_TZ = tz.tzlocal()

# ----------------------------------------------------
# AUTHENTICATION CONFIG
Expand Down Expand Up @@ -106,14 +106,14 @@
# Babel config for translations
# ---------------------------------------------------
# Setup default language
BABEL_DEFAULT_LOCALE = 'en'
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'},
# 'fr': {'flag': 'fr', 'name': 'French'},
# 'zh': {'flag': 'cn', 'name': 'Chinese'},
'zh': {'flag': 'cn', 'name': 'Chinese'},
}
# ---------------------------------------------------
# Image and file configuration
Expand Down
3 changes: 2 additions & 1 deletion caravel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ def dttm_converter(self, dttm):
'oracle':
"""TO_TIMESTAMP('{}', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')""".format(
dttm.isoformat()),
'presto': default,
'presto': "CAST('{}' AS TIMESTAMP)".format(
dttm.strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]),
'sqlite': default,
}
for k, v in d.items():
Expand Down
10 changes: 10 additions & 0 deletions caravel/templates/appbuilder/navbar_menu.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>

</body>
</html>
4 changes: 2 additions & 2 deletions caravel/templates/caravel/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h3>{{ _("Welcome!") }}</h3>
<div class="row">
<div class="col-md-12">
<span class="pull-left">
<h5><i class="fa fa-dashboard"></i> Dashboards</h5>
<h5><i class="fa fa-dashboard"></i> {{ _('Dashboards') }}</h5>
</span>
<span class="search pull-right"></span>
<span class="pull-right">
Expand All @@ -43,7 +43,7 @@ <h5><i class="fa fa-search"></i></h5>
<div class="row">
<div class="col-md-12">
<span class="pull-left">
<h5><i class="fa fa-bar-chart"></i> Slices</h5>
<h5><i class="fa fa-bar-chart"></i> {{ _('Slices') }}</h5>
</span>
<span class="search pull-right"></span>
<span class="pull-right">
Expand Down
Binary file removed caravel/translations/zh/LC_MESSAGES/messages.mo
Binary file not shown.
Loading