izi18n
Simple python library for language Internationalisation
Install
pip install izi18n
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
from izi18n import init_translation
init_translation(language="en", translations_path="../exemples/locales")
from izi18n import translate, gettext, _
print(translate('page.facture.title'))
translate("page.facture.count", default_text="Total facture", **dict(item=5, total=20))
translate("page.facture.count", default_text="Total facture", item=5, total=20)
print(gettext('page.facture.title'))
print(_('page.facture.title'))
from izi18n import translate
print(translate("space key"))
translate("cinego")
print(translate("space key 2.Good for me"))
from izi18n import get_i18n, get_locale
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_file(['app.po', 'messages.po'], "de", stream=True)
print(get_locale())
print(translate("Dimanche"))
print(gettext("Lundi"))
print(_("Visit ${url}", url="https://github.com/cnfilms/izi18n"))
from izi18n import init_translation, add_translation, add_translation_by_lang
init_translation(language="fr", translations_path="../exemples/locales")
add_translation(pattern="page.home.title", value="Bonjour")
add_translation_by_lang(lang="en", pattern="page.home.title", value="Hi!")
add_translation(pattern="page.home.docs", value="Documents", lang="en")