okrand


Nameokrand JSON
Version 1.3.0 PyPI version JSON
download
home_pagehttps://github.com/boxed/okrand
SummaryOkrand is an internationalization/translation tool for Django
upload_time2024-11-06 11:43:53
maintainerNone
docs_urlNone
authorAnders Hovmöller
requires_pythonNone
licenseBSD
keywords okrand
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            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
    django_model_prefixes=
        your_package.

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

.. 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
 - custom collector functions


.. code-block::

    [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


Installing the frontend
=======================


There is a built in web based frontend to okrand. To install it first `install iommi <https://docs.iommi.rocks/en/latest/getting_started.html>`_.

Then add the following to your ``urls.py``:

.. code-block:: python

    from okrand.views import i18n

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


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": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "okrand",
    "author": "Anders Hovm\u00f6ller",
    "author_email": "boxed@killingar.net",
    "download_url": "https://files.pythonhosted.org/packages/7a/f4/8aafbc3a906a814cd67051de1888fc69851633b7da9de118d18e30f9491f/okrand-1.3.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    django_model_prefixes=\n        your_package.\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 you 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 - custom collector functions\n\n\n.. code-block::\n\n    [tool:okrand]\n    ignore=\n        .*some_annoying_path.*\n    sort=alphabetical\n    django_model_upgrade=1\n    django_model_prefixes=\n        some_app.\n        another_app.\n    find_source_strings_plugins=\n        your.module.function_name\n\n\nInstalling the frontend\n=======================\n\n\nThere is a built in web based frontend to okrand. To install it first `install iommi <https://docs.iommi.rocks/en/latest/getting_started.html>`_.\n\nThen add the following to your ``urls.py``:\n\n.. code-block:: python\n\n    from okrand.views import i18n\n\n    urlpatterns = [\n        path('i18n/', i18n),\n    ]\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.3.0",
    "project_urls": {
        "Homepage": "https://github.com/boxed/okrand"
    },
    "split_keywords": [
        "okrand"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "932f4653a5afa67a8e36174863e5f9e91a07102fff570dca4ff7a116f9bc721c",
                "md5": "d886cb55515bc0118d1cc722894da9bf",
                "sha256": "d33ff6988073dab6f398a81f769f3a39c63ee57a6eaf8f77de9bc9c06e9dd64f"
            },
            "downloads": -1,
            "filename": "okrand-1.3.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d886cb55515bc0118d1cc722894da9bf",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 29031,
            "upload_time": "2024-11-06T11:43:51",
            "upload_time_iso_8601": "2024-11-06T11:43:51.378464Z",
            "url": "https://files.pythonhosted.org/packages/93/2f/4653a5afa67a8e36174863e5f9e91a07102fff570dca4ff7a116f9bc721c/okrand-1.3.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7af48aafbc3a906a814cd67051de1888fc69851633b7da9de118d18e30f9491f",
                "md5": "ee1e7e29e49fa81005da9b669379cfe4",
                "sha256": "d3d99f1503cb30c2ef7b4003e4f0cc76ed94bd29bc00b39d9f15df97e64a8456"
            },
            "downloads": -1,
            "filename": "okrand-1.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ee1e7e29e49fa81005da9b669379cfe4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 30130,
            "upload_time": "2024-11-06T11:43:53",
            "upload_time_iso_8601": "2024-11-06T11:43:53.160115Z",
            "url": "https://files.pythonhosted.org/packages/7a/f4/8aafbc3a906a814cd67051de1888fc69851633b7da9de118d18e30f9491f/okrand-1.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-06 11:43:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "boxed",
    "github_project": "okrand",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "okrand"
}
        
Elapsed time: 0.39134s