V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
mzmxcvbn
V2EX  ›  Python

国际化 flask-babel,是只能用 _ 吗

  •  
  •   mzmxcvbn · 2019-06-27 16:58:31 +08:00 · 1542 次点击
    这是一个创建于 1759 天前的主题,其中的信息可能已经有所发展或是发生改变。
    为了简便,需要翻译的文本一般用
    from flask_babel import gettext as _
    _('hello)
    来提取,

    但我代码里用到 _ 来充当之后不用的变量了,所以会冲突,我就用了
    from flask_babel import gettext as _g
    _g('hello)
    但是发现,这样
    pybabel extract
    就探测不到文本了。这是啥情况,是只能用 _ 吗,有什么方法能解决,直接用 gettext 太丑了
    2 条回复    2019-07-01 10:01:53 +08:00
    sunhk25
        1
    sunhk25  
       2019-06-27 20:25:12 +08:00 via Android
    最近在学习 flask,同样感兴趣
    mzmxcvbn
        2
    mzmxcvbn  
    OP
       2019-07-01 10:01:53 +08:00
    有大神能解答一下吗
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2926 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 14:04 · PVG 22:04 · LAX 07:04 · JFK 10:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.