Skip to main content

izi18n Downloads

Simple python library for language Internationalisation

Install

pip install izi18n
  • 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
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
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
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
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
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
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")

Release files for izi18n 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for izi18n 1.0.2
File Size Uploaded
izi18n-1.0.2.tar.gz 18.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for izi18n 1.0.2
File Interpreter ABI Platform
izi18n-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 30.9 kB

Release files / izi18n-1.0.2.tar.gz

Download URL izi18n-1.0.2.tar.gz
Size 18.5 kB
Tags Source
SHA-256 checksum
How to use checksums
33d563ff28d73c09fb4dcf1adea01eb04200cf8a86405e08d0c8d63a1a746853
BLAKE2b-256 checksum
How to use checksums
9b147acaab67fff9b75cacddfb0946d9b89308985619e88ff368944294af1f24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / izi18n-1.0.2-py3-none-any.whl

Download URL izi18n-1.0.2-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f925debb3142e3806f877a42fa5caa3fe283ac3b704166fb58f619bcead463de
BLAKE2b-256 checksum
How to use checksums
ce7f1df4168f62534a144624d334a7ade1c7df9b291b72179fce472735c13e57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page