django-translatemessages


Namedjango-translatemessages JSON
Version 0.0.5 PyPI version JSON
download
home_pagehttps://github.com/elapouya/django-translatemessages
SummaryTranslate Django .po files
upload_time2023-06-29 08:24:11
maintainer
docs_urlNone
authorEric Lapouyade
requires_python
licenseMIT
keywords table datatable listing data grid
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
========================
django-translatemessages
========================

Django app for translating Django .po files.
It uses `deep-translator <https://pypi.org/project/deep-translator/>`_ and
`polib <https://github.com/izimobil/polib/>`_

Installation
------------

when using pip::

    pip install django-translatemessages

When using poetry::

    poetry add django-translatemessages


Configuration
-------------

You must declare in your ``settings.py`` what translator to use and its params.
Please refer to `deep-translator Translators <https://deep-translator.readthedocs.io/en/latest/usage.html>`_
to know what parameters to specify (Note that ``django-translatemessages`` automatically add ``source`` and ``target`` parameters)

To configure GoogleTranslator, add in your ``settings.py``::

    TRANSLATEMESSAGES_PARAMS = {
        "translator": {
            "class": "GoogleTranslator",
            "params": {},
        },
    }


To configure DeeplTranslator, you will need an API key, add in your ``settings.py``::

    TRANSLATEMESSAGES_PARAMS = {
        "translator": {
            "class": "DeeplTranslator",
            "params": {
                "api_key": "your deepl api key",
            },
        },
    }

A good pratice in a Django application is to encapsulate strings to be translated into square brakets,
thus, you will noticed at once what strings has not been translated yet.
You can ask ``django-translatemessages`` to extract the string to translate from the source string.
Use a regex which selects with parentheses the text to extract. Note that if there is no match, the translation will not occur.

For example if you want to translate ``[my english string]`` into ``my french string`` with deepl, put in ``settings.py``::

    TRANSLATEMESSAGES_PARAMS = {
        "extract_regex": r"\[(.*)\]",
        "translator": {
            "class": "DeeplTranslator",
            "params": {
                "api_key": "your deepl api key",
            },
        },
    }

The source language is ``en`` by default, but you can use another one in your ``settings.py``::

    TRANSLATEMESSAGES_PARAMS = {
        "source_lang": "fr",
        ...
    }

**IMPORTANT :** By default, ``django-translatemessages`` will produce translations with the flag ``fuzzy``.
This force the developer to validate manually each translation.

To do so, edit each ``django.po`` file, search for the line ``#, fuzzy`` and remove it if you agree with the proposed translation. If you do not do this,
Django will not display the translation. You can also use `poedit <https://poedit.net/>`_
and press ``CTRL + RETURN`` on each highlighted translation you agree.

To disable auto-fuzzy feature, use this in your ``settings.py``::

    TRANSLATEMESSAGES_PARAMS = {
        "auto_fuzzy": False,
        ...
    }


Usage
-----

To auto-translate all languages in all apps::

    python ./manage.py translatemessages

Do not forget to do a ``makemessages`` before if needed (See Django documentation)

For more options, run ``python ./manage.py translatemessages -h``


News
----

0.0.5 (2023-06-29)
------------------
- Force translation of fuzzy strings except when obsolete or already translated
  by django-translatemessages

0.0.4 (2023-06-21)
------------------
- Do not translate fuzzy strings

0.0.2 (2023-06-11)
------------------
- First commit


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/elapouya/django-translatemessages",
    "name": "django-translatemessages",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "table,datatable,listing,data grid",
    "author": "Eric Lapouyade",
    "author_email": "elapouya@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/7e/cf/6e8628a530140076e62238418fa38584611cfc5b0d97a2532f830fcfe941/django-translatemessages-0.0.5.tar.gz",
    "platform": null,
    "description": "\n========================\ndjango-translatemessages\n========================\n\nDjango app for translating Django .po files.\nIt uses `deep-translator <https://pypi.org/project/deep-translator/>`_ and\n`polib <https://github.com/izimobil/polib/>`_\n\nInstallation\n------------\n\nwhen using pip::\n\n    pip install django-translatemessages\n\nWhen using poetry::\n\n    poetry add django-translatemessages\n\n\nConfiguration\n-------------\n\nYou must declare in your ``settings.py`` what translator to use and its params.\nPlease refer to `deep-translator Translators <https://deep-translator.readthedocs.io/en/latest/usage.html>`_\nto know what parameters to specify (Note that ``django-translatemessages`` automatically add ``source`` and ``target`` parameters)\n\nTo configure GoogleTranslator, add in your ``settings.py``::\n\n    TRANSLATEMESSAGES_PARAMS = {\n        \"translator\": {\n            \"class\": \"GoogleTranslator\",\n            \"params\": {},\n        },\n    }\n\n\nTo configure DeeplTranslator, you will need an API key, add in your ``settings.py``::\n\n    TRANSLATEMESSAGES_PARAMS = {\n        \"translator\": {\n            \"class\": \"DeeplTranslator\",\n            \"params\": {\n                \"api_key\": \"your deepl api key\",\n            },\n        },\n    }\n\nA good pratice in a Django application is to encapsulate strings to be translated into square brakets,\nthus, you will noticed at once what strings has not been translated yet.\nYou can ask ``django-translatemessages`` to extract the string to translate from the source string.\nUse a regex which selects with parentheses the text to extract. Note that if there is no match, the translation will not occur.\n\nFor example if you want to translate ``[my english string]`` into ``my french string`` with deepl, put in ``settings.py``::\n\n    TRANSLATEMESSAGES_PARAMS = {\n        \"extract_regex\": r\"\\[(.*)\\]\",\n        \"translator\": {\n            \"class\": \"DeeplTranslator\",\n            \"params\": {\n                \"api_key\": \"your deepl api key\",\n            },\n        },\n    }\n\nThe source language is ``en`` by default, but you can use another one in your ``settings.py``::\n\n    TRANSLATEMESSAGES_PARAMS = {\n        \"source_lang\": \"fr\",\n        ...\n    }\n\n**IMPORTANT :** By default, ``django-translatemessages`` will produce translations with the flag ``fuzzy``.\nThis force the developer to validate manually each translation.\n\nTo do so, edit each ``django.po`` file, search for the line ``#, fuzzy`` and remove it if you agree with the proposed translation. If you do not do this,\nDjango will not display the translation. You can also use `poedit <https://poedit.net/>`_\nand press ``CTRL + RETURN`` on each highlighted translation you agree.\n\nTo disable auto-fuzzy feature, use this in your ``settings.py``::\n\n    TRANSLATEMESSAGES_PARAMS = {\n        \"auto_fuzzy\": False,\n        ...\n    }\n\n\nUsage\n-----\n\nTo auto-translate all languages in all apps::\n\n    python ./manage.py translatemessages\n\nDo not forget to do a ``makemessages`` before if needed (See Django documentation)\n\nFor more options, run ``python ./manage.py translatemessages -h``\n\n\nNews\n----\n\n0.0.5 (2023-06-29)\n------------------\n- Force translation of fuzzy strings except when obsolete or already translated\n  by django-translatemessages\n\n0.0.4 (2023-06-21)\n------------------\n- Do not translate fuzzy strings\n\n0.0.2 (2023-06-11)\n------------------\n- First commit\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Translate Django .po files",
    "version": "0.0.5",
    "project_urls": {
        "Homepage": "https://github.com/elapouya/django-translatemessages"
    },
    "split_keywords": [
        "table",
        "datatable",
        "listing",
        "data grid"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "639db5832092141b201c19d6a1f452286b68430ca13149cb91ac043c91bd49f0",
                "md5": "59e4ab0f78742ae1b3fc32427a9051fe",
                "sha256": "e2271c1d7f6f2865d66bf9625cc3205b4fae2a569d9e4c98b32a24d80b770f00"
            },
            "downloads": -1,
            "filename": "django_translatemessages-0.0.5-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "59e4ab0f78742ae1b3fc32427a9051fe",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 7507,
            "upload_time": "2023-06-29T08:24:10",
            "upload_time_iso_8601": "2023-06-29T08:24:10.143062Z",
            "url": "https://files.pythonhosted.org/packages/63/9d/b5832092141b201c19d6a1f452286b68430ca13149cb91ac043c91bd49f0/django_translatemessages-0.0.5-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7ecf6e8628a530140076e62238418fa38584611cfc5b0d97a2532f830fcfe941",
                "md5": "078ab61335f8733a572d9c8c1677822c",
                "sha256": "9ded329e147d400240d39e778b1f9a4af9ac15a884b7ee4855a2fa1452756bc5"
            },
            "downloads": -1,
            "filename": "django-translatemessages-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "078ab61335f8733a572d9c8c1677822c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7577,
            "upload_time": "2023-06-29T08:24:11",
            "upload_time_iso_8601": "2023-06-29T08:24:11.796406Z",
            "url": "https://files.pythonhosted.org/packages/7e/cf/6e8628a530140076e62238418fa38584611cfc5b0d97a2532f830fcfe941/django-translatemessages-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-29 08:24:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "elapouya",
    "github_project": "django-translatemessages",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "django-translatemessages"
}
        
Elapsed time: 0.18683s