Skip to main content

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:

[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.

Metadata

Release files for okrand 1.8.0

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.8.0
File Size Uploaded Provenance
okrand-1.8.0.tar.gz 33.1 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 61.8 kB

Release files / okrand-1.8.0.tar.gz

Download URL okrand-1.8.0.tar.gz
Size 33.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6a630b6454b61395fba299f6c3164366e9ac7b09717bb0d00dfa9a11e1d5317c
BLAKE2b-256 checksum
How to use checksums
58a54ae7e7d076b7ebef54db33b4172193624749b51e7e5c208cb16e121f4eb9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / okrand-1.8.0-py3-none-any.whl

Download URL okrand-1.8.0-py3-none-any.whl
Size 28.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd1ac9e27eb12703a429296d89a76ab917d95f59a5237f887dc1dcdf6649b0aa
BLAKE2b-256 checksum
How to use checksums
295135883dc3f6db1b67988411ff31d5a51afee8d73b23921de5d8ec263a4f72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for okrand 1.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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