doti18n


Namedoti18n JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryPython library for loading YAML localizations with dot access and pluralization.
upload_time2025-07-13 14:21:51
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords localization i18n l10n translate yaml json yml text processing dot access pluralization babel
VCS
bugtrack_url
requirements PyYaml babel build twine
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # doti18n [![PyPI version](https://badge.fury.io/py/doti18n.svg)](https://pypi.org/project/doti18n/) [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/darkj3suss/doti18n/blob/main/LICENSE)

Simple and intuitive Python library for loading localizations from YAML files and accessing them easily using dot notation, with powerful support for plural forms and nested data structures.

## Description

doti18n provides a convenient way to manage your application's localization strings. By loading data from standard YAML files, the library allows you to access nested translations using a simple **dot syntax (`messages.status.online`) for dictionary keys** and **index syntax (`items[0]`) for list elements**. You can combine these for intuitive navigation through complex nested structures (`pages[0].title`).

Special attention is given to pluralization support using the [Babel](https://pypi.org/project/babel/) library, which is critical for correct localization across different languages. An automatic fallback mechanism to the default locale's value is also implemented if a key or path is missing in the requested locale.

The library offers both a forgiving non-strict mode (returning a special wrapper and logging warnings) and a strict mode (raising exceptions) for handling missing paths.

It's designed for ease of use and performance (data is loaded once during initialization and translator objects are cached).

## Features

*   Loading localization data from YAML files.
*   Intuitive access to nested data structures (dictionaries and lists) using **dot notation (`.`) for dictionary keys and index notation (`[]`) for list elements**.
*   Support for **combined access paths** (`data.list[0].nested_key`).
*   **Strict mode** (`strict=True`) to raise exceptions (`AttributeError`, `IndexError`, `TypeError`) on missing paths or incorrect usage.
*   **Non-strict mode** (default) to return a special `NoneWrapper` object and log a warning on missing paths.
*   Pluralization support for count-dependent strings (requires `Babel`).
*   Automatic fallback to the default locale if a key/path is missing in the current locale.
*   Caching of loaded data and translator objects for efficient access.
*   Handles explicit `null` values in YAML, distinguishing them from missing paths.

## Installation

doti18n is available on [PyPI](https://pypi.org/project/doti18n/).

Install the basic version (without pluralization support):

```bash
pip install doti18n
```

For pluralization support (recommended), install with the optional `pluralization` dependency:

```bash
pip install doti18n[pluralization]
```

**Note:** Pluralization support is implemented using the [Babel](https://pypi.org/project/babel/) library. If you install doti18n without the `[pluralization]` optional dependency, pluralization functionality will be limited or unavailable, and the library will log a warning about the missing Babel dependency.

## Project Status

This project is in an early stage of development (**Alpha**). The API may change in future versions before reaching a stable (1.0.0) release. Any feedback and suggestions are welcome!

## License

This project is licensed under the MIT License. See the [LICENSE](https://github.com/darkj3suss/doti18n/blob/main/LICENSE) file for details.

## Contact

If you have questions, feel free to open an issue on GitHub.
Or you can message me on [Telegram](https://t.me/darkjesuss)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "doti18n",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "localization, i18n, l10n, translate, yaml, json, yml, text processing, dot access, pluralization, babel",
    "author": null,
    "author_email": "darkj3suss <asdzxco@protonmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/49/58/df2eff48906b1e256cb3dc4653c338bb37d79bebfbf9b9098e8abe903542/doti18n-0.2.0.tar.gz",
    "platform": null,
    "description": "# doti18n [![PyPI version](https://badge.fury.io/py/doti18n.svg)](https://pypi.org/project/doti18n/) [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/darkj3suss/doti18n/blob/main/LICENSE)\r\n\r\nSimple and intuitive Python library for loading localizations from YAML files and accessing them easily using dot notation, with powerful support for plural forms and nested data structures.\r\n\r\n## Description\r\n\r\ndoti18n provides a convenient way to manage your application's localization strings. By loading data from standard YAML files, the library allows you to access nested translations using a simple **dot syntax (`messages.status.online`) for dictionary keys** and **index syntax (`items[0]`) for list elements**. You can combine these for intuitive navigation through complex nested structures (`pages[0].title`).\r\n\r\nSpecial attention is given to pluralization support using the [Babel](https://pypi.org/project/babel/) library, which is critical for correct localization across different languages. An automatic fallback mechanism to the default locale's value is also implemented if a key or path is missing in the requested locale.\r\n\r\nThe library offers both a forgiving non-strict mode (returning a special wrapper and logging warnings) and a strict mode (raising exceptions) for handling missing paths.\r\n\r\nIt's designed for ease of use and performance (data is loaded once during initialization and translator objects are cached).\r\n\r\n## Features\r\n\r\n*   Loading localization data from YAML files.\r\n*   Intuitive access to nested data structures (dictionaries and lists) using **dot notation (`.`) for dictionary keys and index notation (`[]`) for list elements**.\r\n*   Support for **combined access paths** (`data.list[0].nested_key`).\r\n*   **Strict mode** (`strict=True`) to raise exceptions (`AttributeError`, `IndexError`, `TypeError`) on missing paths or incorrect usage.\r\n*   **Non-strict mode** (default) to return a special `NoneWrapper` object and log a warning on missing paths.\r\n*   Pluralization support for count-dependent strings (requires `Babel`).\r\n*   Automatic fallback to the default locale if a key/path is missing in the current locale.\r\n*   Caching of loaded data and translator objects for efficient access.\r\n*   Handles explicit `null` values in YAML, distinguishing them from missing paths.\r\n\r\n## Installation\r\n\r\ndoti18n is available on [PyPI](https://pypi.org/project/doti18n/).\r\n\r\nInstall the basic version (without pluralization support):\r\n\r\n```bash\r\npip install doti18n\r\n```\r\n\r\nFor pluralization support (recommended), install with the optional `pluralization` dependency:\r\n\r\n```bash\r\npip install doti18n[pluralization]\r\n```\r\n\r\n**Note:** Pluralization support is implemented using the [Babel](https://pypi.org/project/babel/) library. If you install doti18n without the `[pluralization]` optional dependency, pluralization functionality will be limited or unavailable, and the library will log a warning about the missing Babel dependency.\r\n\r\n## Project Status\r\n\r\nThis project is in an early stage of development (**Alpha**). The API may change in future versions before reaching a stable (1.0.0) release. Any feedback and suggestions are welcome!\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License. See the [LICENSE](https://github.com/darkj3suss/doti18n/blob/main/LICENSE) file for details.\r\n\r\n## Contact\r\n\r\nIf you have questions, feel free to open an issue on GitHub.\r\nOr you can message me on [Telegram](https://t.me/darkjesuss)\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python library for loading YAML localizations with dot access and pluralization.",
    "version": "0.2.0",
    "project_urls": {
        "BugTracker": "https://github.com/darkj3suss/doti18n/issues",
        "Homepage": "https://github.com/darkj3suss/doti18n",
        "Repository": "https://github.com/darkj3suss/doti18n"
    },
    "split_keywords": [
        "localization",
        " i18n",
        " l10n",
        " translate",
        " yaml",
        " json",
        " yml",
        " text processing",
        " dot access",
        " pluralization",
        " babel"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1737fafce66adb897a1f68e3c4808357a571ce09e1c9a43e1a52e2b931de01e6",
                "md5": "58aee88ac3561db7f09d3d5dd2e3f434",
                "sha256": "b84f74cc3c955464db33b17935feddcf0becdb20d41e293a16a4b3623c157a9b"
            },
            "downloads": -1,
            "filename": "doti18n-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "58aee88ac3561db7f09d3d5dd2e3f434",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 20740,
            "upload_time": "2025-07-13T14:21:50",
            "upload_time_iso_8601": "2025-07-13T14:21:50.472155Z",
            "url": "https://files.pythonhosted.org/packages/17/37/fafce66adb897a1f68e3c4808357a571ce09e1c9a43e1a52e2b931de01e6/doti18n-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4958df2eff48906b1e256cb3dc4653c338bb37d79bebfbf9b9098e8abe903542",
                "md5": "bf872f627fbc4bf7890f51687f9229f3",
                "sha256": "7b4986cbf75023001b3aabe02b2f66d02ef02c1ed6da61866164815b41f5a37a"
            },
            "downloads": -1,
            "filename": "doti18n-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bf872f627fbc4bf7890f51687f9229f3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 22219,
            "upload_time": "2025-07-13T14:21:51",
            "upload_time_iso_8601": "2025-07-13T14:21:51.688229Z",
            "url": "https://files.pythonhosted.org/packages/49/58/df2eff48906b1e256cb3dc4653c338bb37d79bebfbf9b9098e8abe903542/doti18n-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-13 14:21:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "darkj3suss",
    "github_project": "doti18n",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "PyYaml",
            "specs": [
                [
                    "==",
                    "6.0.2"
                ]
            ]
        },
        {
            "name": "babel",
            "specs": [
                [
                    "==",
                    "2.17.0"
                ]
            ]
        },
        {
            "name": "build",
            "specs": []
        },
        {
            "name": "twine",
            "specs": []
        }
    ],
    "lcname": "doti18n"
}
        
Elapsed time: 0.69330s