Skip to content

Commit

Permalink
add locale support for update_bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
EricWang committed Feb 28, 2017
1 parent e82f962 commit 960898e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
19 changes: 9 additions & 10 deletions messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2017-02-28 15:07+0800\n"
"POT-Creation-Date: 2017-02-28 15:22+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -38,37 +38,36 @@ msgstr ""
msgid "benchmark {benchmark} has been de_listed on {end_date}"
msgstr ""

#: rqalpha/main.py:124
#: rqalpha/main.py:119
msgid ""
"\n"
"[WARNING]\n"
"Target bundle path {data_bundle_path} is not empty.\n"
"The content of this folder will be REMOVED before updating.\n"
"Are you sure to continue?\n"
" "
"Are you sure to continue?"
msgstr ""

#: rqalpha/main.py:132
#: rqalpha/main.py:131
msgid "try {} ..."
msgstr ""

#: rqalpha/main.py:141
#: rqalpha/main.py:140
msgid "downloading ..."
msgstr ""

#: rqalpha/main.py:155
#: rqalpha/main.py:154
msgid "Data bundle download successfully in {bundle_path}"
msgstr ""

#: rqalpha/main.py:295
#: rqalpha/main.py:294
msgid "unknown event from event source: {}"
msgstr ""

#: rqalpha/main.py:301
#: rqalpha/main.py:300
msgid "strategy run successfully, normal exit"
msgstr ""

#: rqalpha/main.py:310 rqalpha/main.py:323 rqalpha/main.py:326
#: rqalpha/main.py:309 rqalpha/main.py:322 rqalpha/main.py:325
msgid "strategy execute exception"
msgstr ""

Expand Down
5 changes: 3 additions & 2 deletions rqalpha/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ def entry_point():

@cli.command()
@click.option('-d', '--data-bundle-path', default=os.path.expanduser("~/.rqalpha"), type=click.Path(file_okay=False))
def update_bundle(data_bundle_path):
@click.option('--locale', 'locale', type=click.STRING, default="zh_Hans_CN")
def update_bundle(data_bundle_path, locale):
"""
Sync Data Bundle
"""
from . import main
main.update_bundle(data_bundle_path)
main.update_bundle(data_bundle_path, locale)


@cli.command()
Expand Down
10 changes: 5 additions & 5 deletions rqalpha/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
from .mod.mod_handler import ModHandler
from .model.bar import BarMap
from .model.account import MixedAccount
from .utils import create_custom_exception, run_with_user_log_disabled
from .utils import create_custom_exception, run_with_user_log_disabled, scheduler as mod_scheduler
from .utils.exception import CustomException, is_user_exc, patch_user_exc
from .utils.i18n import gettext as _
from .utils.logger import user_log, user_system_log, system_log, user_print, user_detail_log
from .utils.persisit_helper import CoreObjectsPersistProxy, PersistHelper
from .utils.scheduler import Scheduler
from .utils import scheduler as mod_scheduler
from .utils.config import set_locale


jsonpickle_numpy.register_handlers()
Expand Down Expand Up @@ -108,7 +108,8 @@ def create_base_scope():
return scope


def update_bundle(data_bundle_path=None, confirm=True):
def update_bundle(data_bundle_path=None, locale="zh_Hans_CN", confirm=True):
set_locale(locale)
default_bundle_path = os.path.abspath(os.path.expanduser("~/.rqalpha/bundle/"))
if data_bundle_path is None:
data_bundle_path = default_bundle_path
Expand All @@ -120,8 +121,7 @@ def update_bundle(data_bundle_path=None, confirm=True):
[WARNING]
Target bundle path {data_bundle_path} is not empty.
The content of this folder will be REMOVED before updating.
Are you sure to continue?
""".format(data_bundle_path=data_bundle_path)), abort=True)
Are you sure to continue?""").format(data_bundle_path=data_bundle_path), abort=True)

day = datetime.date.today()
tmp = os.path.join(tempfile.gettempdir(), 'rq.bundle')
Expand Down
Binary file modified rqalpha/utils/translations/zh_Hans_CN/LC_MESSAGES/messages.mo
Binary file not shown.
20 changes: 9 additions & 11 deletions rqalpha/utils/translations/zh_Hans_CN/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2017-02-28 15:07+0800\n"
"POT-Creation-Date: 2017-02-28 15:22+0800\n"
"PO-Revision-Date: 2016-10-24 21:20+0800\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: zh_Hans_CN\n"
Expand Down Expand Up @@ -41,43 +41,41 @@ msgstr "benchmark {benchmark} 在 {start_date} 还未上市。请重新选择起
msgid "benchmark {benchmark} has been de_listed on {end_date}"
msgstr "benchmark {benchmark} 在 {end_date} 已退市。请重新选择结束日期或benchmark。"

#: rqalpha/main.py:124
#: rqalpha/main.py:119
msgid ""
"\n"
"[WARNING]\n"
"Target bundle path {data_bundle_path} is not empty.\n"
"The content of this folder will be REMOVED before updating.\n"
"Are you sure to continue?\n"
" "
"Are you sure to continue?"
msgstr ""
"\n"
"[WARNING]\n"
"目标数据源路径 {data_bundle_path} 不为空\n"
"更新操作首先会清空该文件件下所有内容\n"
"您确定要继续吗?\n"
" "

#: rqalpha/main.py:132
#: rqalpha/main.py:131
msgid "try {} ..."
msgstr "尝试 {} ..."

#: rqalpha/main.py:141
#: rqalpha/main.py:140
msgid "downloading ..."
msgstr "下载中 ..."

#: rqalpha/main.py:155
#: rqalpha/main.py:154
msgid "Data bundle download successfully in {bundle_path}"
msgstr "数据下载成功: {bundle_path}"

#: rqalpha/main.py:295
#: rqalpha/main.py:294
msgid "unknown event from event source: {}"
msgstr "从 event source 中获取的无效事件: {}"

#: rqalpha/main.py:301
#: rqalpha/main.py:300
msgid "strategy run successfully, normal exit"
msgstr "策略运行成功,正常退出"

#: rqalpha/main.py:310 rqalpha/main.py:323 rqalpha/main.py:326
#: rqalpha/main.py:309 rqalpha/main.py:322 rqalpha/main.py:325
msgid "strategy execute exception"
msgstr "策略运行产生异常"

Expand Down

0 comments on commit 960898e

Please sign in to comment.