Skip to main content

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
django_model_prefixes=
    your_package.

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 you 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

  • custom collector functions

  • turn off rename support

[tool:okrand]
ignore=
    .*some_annoying_path.*
sort=alphabetical
django_model_upgrade=1
django_model_prefixes=
    some_app.
    another_app.
find_source_strings_plugins=
    your.module.function_name
renames=0

Installing the frontend

There is a built in web based frontend to okrand. To install it first install iommi.

Then add the following to your urls.py:

from okrand.views import i18n

urlpatterns = [
    path('i18n/', i18n),
]

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.

Release files for okrand 1.7.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for okrand 1.7.3
File Size Uploaded
okrand-1.7.3.tar.gz 31.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for okrand 1.7.3
File Interpreter ABI Platform
okrand-1.7.3-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 61.3 kB

Release files / okrand-1.7.3.tar.gz

Download URL okrand-1.7.3.tar.gz
Size 31.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7c56e874d06f0ce29bff945ce1d2242b1f7507747993f38045aaa749f4ef0b0b
BLAKE2b-256 checksum
How to use checksums
a27d2df331fde470ad6340459026a0c72e529e778bb8d3950b1ccdcbd4158c73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.11

Release files / okrand-1.7.3-py2.py3-none-any.whl

Download URL okrand-1.7.3-py2.py3-none-any.whl
Size 29.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a24433258e55bb64d9b53771333aef5b492bcc97add4be1c4b63b0bd62e4196c
BLAKE2b-256 checksum
How to use checksums
7644f9c3fe540082c98327f1386d794629ddfed594cb267e7242906931e232b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.11

Release history Release notifications | RSS feed

This release

1.7.3 This release

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page