Skip to main content

Okrand is an internationalization/translation tool for Django

Project description

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:

[tool:okrand]
django_model_upgrade=1

So concretely this model:

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 = _('book')
        verbose_name = _('books')

Can now be changed to the more natural:

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

First pip install okrand, then add okrand to INSTALLED_APPS.

Add OKRAND_STATIC_PATH to settings, pointing to where Okrand should write the JavaScript catalog files. Typically something like:

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

[tool:okrand]
ignore=
    .*some_annoying_path.*
sort=alphabetical
django_model_upgrade=1

What does “Okrand” mean?

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

okrand-1.1.1.tar.gz (29.0 kB view details)

Uploaded Source

Built Distribution

okrand-1.1.1-py2.py3-none-any.whl (28.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file okrand-1.1.1.tar.gz.

File metadata

  • Download URL: okrand-1.1.1.tar.gz
  • Upload date:
  • Size: 29.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for okrand-1.1.1.tar.gz
Algorithm Hash digest
SHA256 35ad4b68dd01b42f6542bba07771271192c33bfa98464c9942f3fd8777e0b10e
MD5 6404016dae9a7a76483a1177a8c27cd6
BLAKE2b-256 79fd67cc665ea93d171e504f7f97cc8271decf0459c58a16a19edaf8458c94e1

See more details on using hashes here.

File details

Details for the file okrand-1.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: okrand-1.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 28.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for okrand-1.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b6dff9ee97a72009dd25b6cc64ef04b193452459152e72f3a37ae20f5d4aaf64
MD5 f5e3274aebb418376b83f1b4f9229c62
BLAKE2b-256 c08630f0adb0a221398fe6167166b993fea982018f8789201ee01a2b77f52aed

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page