izi18n


Nameizi18n JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/cnfilms/izi18n
SummarySimple python library for language Internationalisation
upload_time2023-07-27 16:41:35
maintainer
docs_urlNone
authorJoel ONIPOH
requires_python>=3.3
license
keywords python i18n internationalisation internationalization language po read .po file json translate pattern interpolate translation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # izi18n
`Simple python library for language Internationalisation`

* Support
    * `JSON`
    * `.PO FILES`

# Method
* `_`
* `add_translation`
* `add_translation_by_lang`
* `get_i18n`
* `get_locale`
* `gettext`
* `init_translation`
* `load_po_file`
* `set_locale`
* `set_translations_path`
* `translate`
* `translate_by_lang`

# Usage
* `Initialisation`
```python
from izi18n import init_translation

# Set default language
# Translations_path is where locate all language translations file (JSON file only)
init_translation(language="en", translations_path="../exemples/locales")
```

* `Translate`
```python
from izi18n import translate, gettext, _

# page.facture.title is the pattern to the key you want to translate
print(translate('page.facture.title'))

# Translate template with values
# default_text is set if the pattern is not found
# **dict() is the kwargs
translate("page.facture.count", default_text="Total facture", **dict(item=5, total=20))
# OR
translate("page.facture.count", default_text="Total facture", item=5, total=20)

# Possibility to use gettext or _() instead from translate
print(gettext('page.facture.title'))
print(_('page.facture.title'))
```
* `Translate by Key or Word`
```python
from izi18n import translate

# Translate with word key
print(translate("space key"))
translate("cinego")
print(translate("space key 2.Good for me"))
```

* `Get I18n class object`
```python
from izi18n import get_i18n, get_locale

# Get ui18n Object class
# get_i18n return I18n class (Singleton)
print(get_i18n().language, " OR ", get_locale(), "\n")
print(get_i18n().translate("cinego"))
```

* `Load translation from .PO file`
```python
from izi18n import load_po_file, get_locale, gettext, translate, _

# Load po files and specify the local of the files
# Stream True it means you avoid to merged with json locales folder files
load_po_file(['app.po', 'messages.po'], "de", stream=True)
# load_po_file("cinego.po", "de")
# load_po_file("messages.po", "de")

print(get_locale())

print(translate("Dimanche"))
print(gettext("Lundi"))
print(_("Visit ${url}", url="https://github.com/cnfilms/izi18n"))
```

* `Add or edit translation`
```python
from izi18n import init_translation, add_translation, add_translation_by_lang

init_translation(language="fr", translations_path="../exemples/locales")

# Add to current local
add_translation(pattern="page.home.title", value="Bonjour")

# Use if initial language is not defined
add_translation_by_lang(lang="en", pattern="page.home.title", value="Hi!")
add_translation(pattern="page.home.docs", value="Documents", lang="en")
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cnfilms/izi18n",
    "name": "izi18n",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.3",
    "maintainer_email": "",
    "keywords": "python,i18n,Internationalisation,Internationalization,language,po,read .po file,json,translate pattern,interpolate translation",
    "author": "Joel ONIPOH",
    "author_email": "technique@cinego.net",
    "download_url": "https://files.pythonhosted.org/packages/28/b9/c05fbeef78a7e0e1a93bee76418760a592cb99633c7b10e5afa28a56146f/izi18n-1.0.0.tar.gz",
    "platform": null,
    "description": "# izi18n\n`Simple python library for language Internationalisation`\n\n* Support\n    * `JSON`\n    * `.PO FILES`\n\n# Method\n* `_`\n* `add_translation`\n* `add_translation_by_lang`\n* `get_i18n`\n* `get_locale`\n* `gettext`\n* `init_translation`\n* `load_po_file`\n* `set_locale`\n* `set_translations_path`\n* `translate`\n* `translate_by_lang`\n\n# Usage\n* `Initialisation`\n```python\nfrom izi18n import init_translation\n\n# Set default language\n# Translations_path is where locate all language translations file (JSON file only)\ninit_translation(language=\"en\", translations_path=\"../exemples/locales\")\n```\n\n* `Translate`\n```python\nfrom izi18n import translate, gettext, _\n\n# page.facture.title is the pattern to the key you want to translate\nprint(translate('page.facture.title'))\n\n# Translate template with values\n# default_text is set if the pattern is not found\n# **dict() is the kwargs\ntranslate(\"page.facture.count\", default_text=\"Total facture\", **dict(item=5, total=20))\n# OR\ntranslate(\"page.facture.count\", default_text=\"Total facture\", item=5, total=20)\n\n# Possibility to use gettext or _() instead from translate\nprint(gettext('page.facture.title'))\nprint(_('page.facture.title'))\n```\n* `Translate by Key or Word`\n```python\nfrom izi18n import translate\n\n# Translate with word key\nprint(translate(\"space key\"))\ntranslate(\"cinego\")\nprint(translate(\"space key 2.Good for me\"))\n```\n\n* `Get I18n class object`\n```python\nfrom izi18n import get_i18n, get_locale\n\n# Get ui18n Object class\n# get_i18n return I18n class (Singleton)\nprint(get_i18n().language, \" OR \", get_locale(), \"\\n\")\nprint(get_i18n().translate(\"cinego\"))\n```\n\n* `Load translation from .PO file`\n```python\nfrom izi18n import load_po_file, get_locale, gettext, translate, _\n\n# Load po files and specify the local of the files\n# Stream True it means you avoid to merged with json locales folder files\nload_po_file(['app.po', 'messages.po'], \"de\", stream=True)\n# load_po_file(\"cinego.po\", \"de\")\n# load_po_file(\"messages.po\", \"de\")\n\nprint(get_locale())\n\nprint(translate(\"Dimanche\"))\nprint(gettext(\"Lundi\"))\nprint(_(\"Visit ${url}\", url=\"https://github.com/cnfilms/izi18n\"))\n```\n\n* `Add or edit translation`\n```python\nfrom izi18n import init_translation, add_translation, add_translation_by_lang\n\ninit_translation(language=\"fr\", translations_path=\"../exemples/locales\")\n\n# Add to current local\nadd_translation(pattern=\"page.home.title\", value=\"Bonjour\")\n\n# Use if initial language is not defined\nadd_translation_by_lang(lang=\"en\", pattern=\"page.home.title\", value=\"Hi!\")\nadd_translation(pattern=\"page.home.docs\", value=\"Documents\", lang=\"en\")\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Simple python library for language Internationalisation",
    "version": "1.0.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/cnfilms/izi18n/issues",
        "Changelog": "https://github.com/cnfilms/izi18n/releases",
        "Homepage": "https://github.com/cnfilms/izi18n"
    },
    "split_keywords": [
        "python",
        "i18n",
        "internationalisation",
        "internationalization",
        "language",
        "po",
        "read .po file",
        "json",
        "translate pattern",
        "interpolate translation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bf0c08b2d7e4a00614a9df122ee23660e67aca22cb2f731050c121cca087d124",
                "md5": "584806b5f0df7be3174d77fb333d4c1c",
                "sha256": "5006e2afe6104a33c74c0a5e23566d79ef2a5e3776a3137df61b118eb6753e3e"
            },
            "downloads": -1,
            "filename": "izi18n-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "584806b5f0df7be3174d77fb333d4c1c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.3",
            "size": 11933,
            "upload_time": "2023-07-27T16:41:33",
            "upload_time_iso_8601": "2023-07-27T16:41:33.525079Z",
            "url": "https://files.pythonhosted.org/packages/bf/0c/08b2d7e4a00614a9df122ee23660e67aca22cb2f731050c121cca087d124/izi18n-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "28b9c05fbeef78a7e0e1a93bee76418760a592cb99633c7b10e5afa28a56146f",
                "md5": "28aed81246d11ecd206529331874d113",
                "sha256": "d0d7768c853423e0838f32eb5ca928a8f40bee6e0045bd452b62185e3d567a73"
            },
            "downloads": -1,
            "filename": "izi18n-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "28aed81246d11ecd206529331874d113",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.3",
            "size": 17668,
            "upload_time": "2023-07-27T16:41:35",
            "upload_time_iso_8601": "2023-07-27T16:41:35.167356Z",
            "url": "https://files.pythonhosted.org/packages/28/b9/c05fbeef78a7e0e1a93bee76418760a592cb99633c7b10e5afa28a56146f/izi18n-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-27 16:41:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cnfilms",
    "github_project": "izi18n",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "izi18n"
}
        
Elapsed time: 0.09441s