forked from amandasaurus/django-template-i18n-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit updates the Django i18n lint tool by making the following changes: - Added `.venv` and `.env` to the `.gitignore` file. - Updated the `tox.ini` file to use `py310` as the Python environment. - Added `pytest` as a dependency in the `tox.ini` file. - Removed the `vim-helpers.vim` file. - Updated the `setup.py` file to change the package name to `django-i18n-lint` and the description to "Lint tool to find untranslated text in Django templates". - Updated the `tests.py` file to import `django_i18n_lint` instead of `django_template_i18n_lint`. - Updated the `README.md` file to reflect the changes in the template tag names and added usage examples.
- Loading branch information
Showing
7 changed files
with
55 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ | |
.tox | ||
.coverage | ||
dist/* | ||
.venv | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,41 @@ | ||
Django Template i18n lint | ||
========================= | ||
# Django i18n Lint | ||
|
||
[![Build Status](https://travis-ci.org/rory/django-template-i18n-lint.png?branch=master)](https://travis-ci.org/rory/django-template-i18n-lint) | ||
[![Coverage Status](https://coveralls.io/repos/rory/django-template-i18n-lint/badge.png?branch=master)](https://coveralls.io/r/rory/django-template-i18n-lint?branch=master) | ||
[![PyPI version](https://pypip.in/v/django-template-i18n-lint/badge.png)](https://pypi.python.org/pypi/django-template-i18n-lint) | ||
[![PyPI Downloads](https://pypip.in/d/django-template-i18n-lint/badge.png)](https://pypi.python.org/pypi/django-template-i18n-lint) | ||
A simple script to find non-i18n text in a Django template. | ||
|
||
Note: Since Django 3.1 the template tag was update from `{% trans "" %}` to `{% translate "" %}` and from `{% blocktrans "" %}` to `{% blocktranslate "" %}`. | ||
The old `trans` versions are still recognized by the linter but the string wrapping will change the string to the new `translate` version. | ||
|
||
A simple script to find non-i18n text in a Django template. | ||
## Usage | ||
|
||
It can also automatically wrap the strings in `{% trans "" %}` tags, by running it with the `-r` command-line flag. | ||
The translation will be written to a new file, `<filename>_translated.html`. | ||
To use the Django Template i18n lint tool, you can run the `django_i18n_lint.py` script from the command line like so: | ||
|
||
For more info see [Lint tool to find non-i18n strings in a django template](http://www.technomancy.org/python/django-template-i18n-lint/) | ||
```bash | ||
python django_i18n_lint.py [options] <path_to_your_template> | ||
``` | ||
|
||
Code is copyright Rory McCann 2013, and dual licenced under the GNU GPL version3 (or at your option a later version), and the BSD licence. See the files LICENCE.GPLv3 and LICENCE.BSD for more information | ||
Running this command without any additonal options will output any non-i18n text found in the specified Django template to the command line. | ||
|
||
Please replace `<path_to_your_template>` with the actual path to your Django template file. | ||
|
||
### Options | ||
- `-r`, `--replace`: Ask to wrap the strings in the file in `{% translate "" %}` tags. | ||
- `-o`, `--overwrite`: When replacing the strings, overwrite the original file. If not specified, the file will be saved in a separate file named `X_translated.html`. | ||
- `-f`, `--force`: Force to wrap strings with no questions. | ||
- `-e`, `--exclude`: Exclude these filenames from being linted. This option can be used multiple times to exclude multiple files. | ||
- `-x`, `--accept`: Exclude these regexes from results. This option can be used multiple times to exclude multiple regexes. | ||
|
||
### Examples | ||
|
||
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rory/django-template-i18n-lint/trend.png)](https://bitdeli.com/free "Bitdeli Badge") | ||
|
||
```bash | ||
# Lint all files in the current directory, excluding `exclude1.html` and `exclude2.html` | ||
python django_i18n_lint.py -e exclude1.html -e exclude2.html | ||
|
||
# Lint `file.html`, replacing strings in the file and overwriting the original file | ||
python django_i18n_lint.py -r -o file.html | ||
|
||
# Lint `file.html`, replacing strings in the file without asking for confirmation | ||
python django_i18n_lint.py -r -f file.html | ||
``` | ||
|
||
Code is copyright Rory McCann 2013, and dual licenced under the GNU GPL version3 (or at your option a later version), and the BSD licence. See the files LICENCE.GPLv3 and LICENCE.BSD for more information |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,14 @@ | |
from setuptools import setup | ||
|
||
setup( | ||
name="django-template-i18n-lint", | ||
name="django-i18n-lint", | ||
version="1.2.0", | ||
author="Rory McCann", | ||
author_email="[email protected]", | ||
py_modules=['django_template_i18n_lint'], | ||
py_modules=['django_i18n_lint'], | ||
license='GPLv3+', | ||
url='http://www.technomancy.org/python/django-template-i18n-lint/', | ||
description='Lint tool to find non-trans/blocktrans text in django templates', | ||
test_suite='tests', | ||
description='Lint tool to find untranslated text in django templates', | ||
classifiers=[ | ||
'Development Status :: 5 - Production/Stable', | ||
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', | ||
|
@@ -21,14 +20,11 @@ | |
'Intended Audience :: Developers', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 2', | ||
'Programming Language :: Python :: 2.7', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.3', | ||
'Programming Language :: Python :: 3.10', | ||
], | ||
entry_points={ | ||
'console_scripts': [ | ||
'django-template-i18n-lint = django_template_i18n_lint:main', | ||
'django-i18n-lint = django_i18n_lint:main', | ||
] | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.