flake8-i18n-0.1.0
توضیحات
Warns about incorrect gettext usage.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | flake8-i18n-0.1.0 |
| نام | flake8-i18n |
| نسخه کتابخانه | 0.1.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Vitaliy Kharitonskiy |
| ایمیل نویسنده | gil.gnome@gmail.com |
| آدرس صفحه اصلی | https://github.com/vharitonsky/flake8-i18n |
| آدرس اینترنتی | https://pypi.org/project/flake8-i18n/ |
| مجوز | Free |
.. -*- coding: utf-8 -*-
Flake8 i18n plugin
==========================
Way too often using gettext in python results in one of
the following errors:
_(f"{context_variable}")
Not only gettext will not work here because fstring interpolation
happens before function call, but using gettext tools for collecting
translation keys results in:
File "/usr/lib/python3.6/site-packages/babel/messages/extract.py",
line 480, in extract_python
value = eval(code, {'__builtins__': {}}, {})
File "<string>", line 2, in <module>
NameError: name 'context_variable' is not defined
Similar cases are
_("%s" % value)
and
_("{}".format(value))
which will not trigger a collection error,
but will still result in an incorrect key name in gettext function call.
This flake8 extensions provides basic checks for the above cases.
Install
-------
Install with pip::
$ pip install flake8-i18n
Configure
---------
Add following into your .flake8 file
i18nfuncs =
gettext
ngettext
myfunny_gettext
_
Otherwise the default function name list is
gettext
ngettext
_
Using string interpolation inside gettext will now result in one of the following:
I001 fstring is resolved before function call
I002 format is resolved before function call
I003 printf is resolved before function call
Requirements
------------
- Python 3.6, 3.7
- flake8
License
-------
GNU General Public License v2 (GPLv2)
.. -*- coding: utf-8 -*-
Changelog
=========
0.1.0 (2019-03-02)
------------------
- Basic implementation
نحوه نصب
نصب پکیج whl flake8-i18n-0.1.0:
pip install flake8-i18n-0.1.0.whl
نصب پکیج tar.gz flake8-i18n-0.1.0:
pip install flake8-i18n-0.1.0.tar.gz