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 = _('book')
verbose_name = _('books')
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
============
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:
.. 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/boxed/okrand",
"name": "okrand",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "okrand",
"author": "Anders Hovm\u00f6ller",
"author_email": "boxed@killingar.net",
"download_url": "https://files.pythonhosted.org/packages/e1/22/e0d5e1e7bfa1283f743eed5f52825e264e2480d6167cd5bb0b01aadff703/okrand-1.1.0.tar.gz",
"platform": null,
"description": "Okrand\n------\n\nOkrand is an internationalization/translation tool for Django.\n\nIt is a pure Python program so doesn't rely on ``gettext``.\n\nOkrand will respect your ``.gitignore``.\n\n\nDjango models\n=============\n\nOkrand 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`.\n\nTurn this feature on in your ``setup.cfg``:\n\n.. code-block::\n\n [tool:okrand]\n django_model_upgrade=1\n\nSo concretely this model:\n\n.. code-block:: python\n\n from django.utils.translation import gettext_lazy as _\n\n\n class Book(Model):\n name = CharField(verbose_name=_('name'))\n isbn = CharField(verbose_name=_('ISBN'))\n\n class Meta:\n verbose_name = _('book')\n verbose_name = _('books')\n\nCan now be changed to the more natural:\n\n.. code-block:: python\n\n class Book(Model):\n name = CharField()\n isbn = CharField(verbose_name='ISBN')\n\nNote that I don't need to wrap the ``verbose_name`` in a `gettext_lazy` call anymore.\n\n\nInstallation\n============\n\nFirst ``pip install okrand``, then add ``okrand`` to ``INSTALLED_APPS``.\n\nAdd ``OKRAND_STATIC_PATH`` to settings, pointing to where Okrand should write the JavaScript catalog files. Typically something like:\n\n.. code-block:: python\n\n OKRAND_STATIC_PATH = Path(BASE_DIR) / 'yourproject' / 'base' / 'static'\n\nIf you have a ``base`` app to put common stuff.\n\n\nConfiguration\n=============\n\nIn ``setup.cfg`` you set:\n\n - additional ignore rules beyond ``.gitignore``. These are regexes for the full path.\n - sorting: none (default), alphabetical\n - if the django model upgrade is enabled\n\n\n.. code-block::\n\n [tool:okrand]\n ignore=\n .*some_annoying_path.*\n sort=alphabetical\n django_model_upgrade=1\n\n\nWhat does \"Okrand\" mean?\n~~~~~~~~~~~~~~~~~~~~~~~~\n\n`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.\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "Okrand is an internationalization/translation tool for Django",
"version": "1.1.0",
"split_keywords": [
"okrand"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2c148d60bfadbf6d8cc2cf42e75c087a11889701546a47569cf12cac0780c7db",
"md5": "bf6bfefc9067ad2e5cff19af0aee66b2",
"sha256": "faef92916c499e7177c15d8c9e544d1aefc007293f7ef01533eb924d4facc56f"
},
"downloads": -1,
"filename": "okrand-1.1.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "bf6bfefc9067ad2e5cff19af0aee66b2",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 28140,
"upload_time": "2023-04-04T18:51:23",
"upload_time_iso_8601": "2023-04-04T18:51:23.684729Z",
"url": "https://files.pythonhosted.org/packages/2c/14/8d60bfadbf6d8cc2cf42e75c087a11889701546a47569cf12cac0780c7db/okrand-1.1.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e122e0d5e1e7bfa1283f743eed5f52825e264e2480d6167cd5bb0b01aadff703",
"md5": "64700b8a2db8c1e11dd4a23bbc8b0bcf",
"sha256": "9f42a7e5253fe509738c2efaceb045f445b807765370c91cc52422221f7dc449"
},
"downloads": -1,
"filename": "okrand-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "64700b8a2db8c1e11dd4a23bbc8b0bcf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 28837,
"upload_time": "2023-04-04T18:51:25",
"upload_time_iso_8601": "2023-04-04T18:51:25.458182Z",
"url": "https://files.pythonhosted.org/packages/e1/22/e0d5e1e7bfa1283f743eed5f52825e264e2480d6167cd5bb0b01aadff703/okrand-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-04 18:51:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "boxed",
"github_project": "okrand",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "Django",
"specs": [
[
">=",
"3.2"
]
]
},
{
"name": "gitignorefile",
"specs": []
}
],
"lcname": "okrand"
}