l10n


Namel10n JSON
Version 0.1.5 PyPI version JSON
download
home_pageNone
SummaryA library and CLI for translating Python applications and libraries.
upload_time2023-07-31 08:38:49
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords localization internationalization l10n i18n locale locales translation gettext
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # l10n

A library and CLI for translating Python applications and libraries.

Our main design principle is "Simple things should be simple, complex things should be possible". We streamline the workflow that fits 95% of the projects and allow to configure every small detail to make it possible to fit the remaining 5%. Think about l10n as a high-level and friendly library comparing to low-level and less friendly [locale](https://docs.python.org/3/library/locale.html), [gettext](https://docs.python.org/3/library/gettext.html), and [babel](https://babel.pocoo.org/en/latest/).

Features:

+ **Simple**. We stripped away all unnecessary steps and concepts. All that's left is what is actually relevant for Python.
+ **Type-safe**. All other tools match translation.
+ **Explicit**. No global state, no variable injection. You know exactly what gets translated and to what language.
+ **Zero-dependency runtime**. There are a few small dependencies for CLI but they get installed only on your dev environment. On the production goes only one small library, l10n  itself.
+ **Pure Python**. You can use it with PyPy, Numba, and any other interpreter.
+ **Zero configuration**. The tool knows about the modern Python packaging and automatically discovers the project structure, name, version, and all other relevant metadata.
+ **Well documented**. We make sure that you can pick up the tool without any prior knowledge of the topic.
+ **Compatible with other tools**. We use `*.po` and `*.mo` files that are compatible with [gettext](https://www.gnu.org/software/gettext/) toolchain and all other translation tools.
+ **Self-sufficient, no other tools required**.
+ **Asyncio-compatible and race-condition-free**.
+ **Fast**. All teanslations on the production are compiled into a small and fast binary format.
+ **Small**. We don't include any generated data into the library distribution. Just a little of Python code.
+ **Lazy**. Any data is loaded only when you need it.
+ **Can be used in libraries**. The compiled translations are automatically placed next to your Python code and discovered at runtime.
+ **Versatile**. Most of the libraries in the wild are focused on web applications. This library fits any Python project.

## l10n in 30 seconds

Install l10n:

```bash
python3 -m pip install 'l10n[cli]'
```

And there are all the changes you need to do in your code to support translations for a string:

```python
from l10n import Locales
locales = Locales()

def say_hello(lang='en'):
    loc = locales[lang]
    msg = loc.get('Hello, world!')
    print(msg)
```

Now, let's translate it to Ukrainian:

1. Extract all strings from the code that need to be translated:

    ```bash
    python3 -m l10n extract --lang uk
    ```

1. Translate all extracted strings using Google Translate:

    ```bash
    python3 -m l10n translate
    ```

1. Compile all translations into the binary format:

    ```bash
    python3 -m l10n compile
    ```

That's all! Now, your code supports translations:

```python
from example import say_hello
say_hello(lang='uk')
# Привіт Світ!
```

If you want to manually adjust the translation text, just edit the `languages/en.po` file and run `compile` again. You don't even need to restart your app!

**Read more in the documentation:** [l10n.orsinium.dev](https://l10n.orsinium.dev/).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "l10n",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "localization,internationalization,l10n,i18n,locale,locales,translation,gettext",
    "author": null,
    "author_email": "Gram <gram@orsinium.dev>",
    "download_url": "https://files.pythonhosted.org/packages/18/fa/28b6097db2a4996fd8c9f08f10a9f2aab7238c17efb08f3f9c2e466f50ac/l10n-0.1.5.tar.gz",
    "platform": null,
    "description": "# l10n\n\nA library and CLI for translating Python applications and libraries.\n\nOur main design principle is \"Simple things should be simple, complex things should be possible\". We streamline the workflow that fits 95% of the projects and allow to configure every small detail to make it possible to fit the remaining 5%. Think about l10n as a high-level and friendly library comparing to low-level and less friendly [locale](https://docs.python.org/3/library/locale.html), [gettext](https://docs.python.org/3/library/gettext.html), and [babel](https://babel.pocoo.org/en/latest/).\n\nFeatures:\n\n+ **Simple**. We stripped away all unnecessary steps and concepts. All that's left is what is actually relevant for Python.\n+ **Type-safe**. All other tools match translation.\n+ **Explicit**. No global state, no variable injection. You know exactly what gets translated and to what language.\n+ **Zero-dependency runtime**. There are a few small dependencies for CLI but they get installed only on your dev environment. On the production goes only one small library, l10n  itself.\n+ **Pure Python**. You can use it with PyPy, Numba, and any other interpreter.\n+ **Zero configuration**. The tool knows about the modern Python packaging and automatically discovers the project structure, name, version, and all other relevant metadata.\n+ **Well documented**. We make sure that you can pick up the tool without any prior knowledge of the topic.\n+ **Compatible with other tools**. We use `*.po` and `*.mo` files that are compatible with [gettext](https://www.gnu.org/software/gettext/) toolchain and all other translation tools.\n+ **Self-sufficient, no other tools required**.\n+ **Asyncio-compatible and race-condition-free**.\n+ **Fast**. All teanslations on the production are compiled into a small and fast binary format.\n+ **Small**. We don't include any generated data into the library distribution. Just a little of Python code.\n+ **Lazy**. Any data is loaded only when you need it.\n+ **Can be used in libraries**. The compiled translations are automatically placed next to your Python code and discovered at runtime.\n+ **Versatile**. Most of the libraries in the wild are focused on web applications. This library fits any Python project.\n\n## l10n in 30 seconds\n\nInstall l10n:\n\n```bash\npython3 -m pip install 'l10n[cli]'\n```\n\nAnd there are all the changes you need to do in your code to support translations for a string:\n\n```python\nfrom l10n import Locales\nlocales = Locales()\n\ndef say_hello(lang='en'):\n    loc = locales[lang]\n    msg = loc.get('Hello, world!')\n    print(msg)\n```\n\nNow, let's translate it to Ukrainian:\n\n1. Extract all strings from the code that need to be translated:\n\n    ```bash\n    python3 -m l10n extract --lang uk\n    ```\n\n1. Translate all extracted strings using Google Translate:\n\n    ```bash\n    python3 -m l10n translate\n    ```\n\n1. Compile all translations into the binary format:\n\n    ```bash\n    python3 -m l10n compile\n    ```\n\nThat's all! Now, your code supports translations:\n\n```python\nfrom example import say_hello\nsay_hello(lang='uk')\n# \u041f\u0440\u0438\u0432\u0456\u0442 \u0421\u0432\u0456\u0442!\n```\n\nIf you want to manually adjust the translation text, just edit the `languages/en.po` file and run `compile` again. You don't even need to restart your app!\n\n**Read more in the documentation:** [l10n.orsinium.dev](https://l10n.orsinium.dev/).\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A library and CLI for translating Python applications and libraries.",
    "version": "0.1.5",
    "project_urls": {
        "Source": "https://github.com/orsinium-labs/l10n"
    },
    "split_keywords": [
        "localization",
        "internationalization",
        "l10n",
        "i18n",
        "locale",
        "locales",
        "translation",
        "gettext"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e98e0b33e1dfc46fd03bc8608348f56654c48fd9fde77dbec95e03a543d3b318",
                "md5": "11cd8b4d15690c7a8f033d277a13628e",
                "sha256": "182496aa52cb8774cc1de42f0343ef3f90ddb5251e968c4c6e1dbab60aff5fef"
            },
            "downloads": -1,
            "filename": "l10n-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "11cd8b4d15690c7a8f033d277a13628e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 17868,
            "upload_time": "2023-07-31T08:38:48",
            "upload_time_iso_8601": "2023-07-31T08:38:48.375313Z",
            "url": "https://files.pythonhosted.org/packages/e9/8e/0b33e1dfc46fd03bc8608348f56654c48fd9fde77dbec95e03a543d3b318/l10n-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "18fa28b6097db2a4996fd8c9f08f10a9f2aab7238c17efb08f3f9c2e466f50ac",
                "md5": "f8cebce300df146c6a463693d177899b",
                "sha256": "7acf4cfca9308aaf29153403ca79f54627a99f7087183af3091363737b2027a4"
            },
            "downloads": -1,
            "filename": "l10n-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "f8cebce300df146c6a463693d177899b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 29256,
            "upload_time": "2023-07-31T08:38:49",
            "upload_time_iso_8601": "2023-07-31T08:38:49.974876Z",
            "url": "https://files.pythonhosted.org/packages/18/fa/28b6097db2a4996fd8c9f08f10a9f2aab7238c17efb08f3f9c2e466f50ac/l10n-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-31 08:38:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "orsinium-labs",
    "github_project": "l10n",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "l10n"
}
        
Elapsed time: 0.11937s