Okrand is an internationalization/translation tool for Django
Project description
Okrand
Okrand is an internationalization/translation tool for Django.
It is a pure Python program so doesn't rely on gettext
.
Okrand will respect your .gitignore
.
Django models
Okrand can upgrade Django models so translation is much easier. You don't need to write verbose_name
anymore! And if you do write them Okrand will upgrade raw strings to gettext_lazy
.
Turn this feature on in your setup.cfg
:
.. code-block::
[tool:okrand]
django_model_upgrade=1
So concretely this model:
.. code-block:: python
from django.utils.translation import gettext_lazy as _
class Book(Model):
name = CharField(verbose_name=_('name'))
isbn = CharField(verbose_name=_('ISBN'))
class Meta:
verbose_name = _('author')
verbose_name = _('authors')
Can now be changed to the more natural:
.. code-block:: python
class Book(Model):
name = CharField()
isbn = CharField(verbose_name='ISBN')
Note that I don't need to wrap the verbose_name
in a gettext_lazy
call anymore.
Installation
Add okrand
to INSTALLED_APP
.
Add OKRAND_STATIC_PATH
to settings, pointing to where Okrand should write the JavaScript catalog files. Typically something like:
.. code-block:: python
OKRAND_STATIC_PATH = Path(BASE_DIR) / 'yourproject' / 'base' / 'static'
If you have a base
app to put common stuff.
Configuration
In setup.cfg
you set:
- additional ignore rules beyond
.gitignore
. These are regexes for the full path. - sorting: none (default), alphabetical
- if the django model upgrade is enabled
.. code-block::
[tool:okrand]
ignore=
.*some_annoying_path.*
sort=alphabetical
django_model_upgrade=1
What does "Okrand" mean?
`Marc Okrand <https://en.wikipedia.org/wiki/Marc_Okrand>`_ is a linguist who is best known for his work on Star Trek where he created the Klingon language.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file okrand-1.0.0.tar.gz
.
File metadata
- Download URL: okrand-1.0.0.tar.gz
- Upload date:
- Size: 28.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57722bd0d0a90e6992ceb9583399257ed77c0f4d3052c8357b1b926aa31f143c |
|
MD5 | 94bc73d5a765ac5a38d8ff811bc4abd6 |
|
BLAKE2b-256 | 8d9377f056b2e6dc45d40170de14978f2f82f0b9147862e8d213a8b742c08cff |
File details
Details for the file okrand-1.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: okrand-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 27.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bdaa642fc3f6dcc8ba78f186aba6bb627549bd7959c642a1fa13fc17a6afc4c |
|
MD5 | 5567246502497b6a4aad94243103a9fd |
|
BLAKE2b-256 | 633de75ad0ec6af7c9e525af19b9b341002b3de93e3f1166f576425241af363f |