Skip to main content

Forge i18n — traduction par catalogues JSON, locale par défaut et fallback, helper trans() pour Jinja.

Project description

forge-mvc-i18n

Opt-in Forge pour l'internationalisation. Extrait du core (ADR-027) : le core ne contient que les primitives générales ; la traduction est une brique spécialisée, optionnelle.

Contenu

  • trans(key, locale=None, translations_dir="translations") : traduit une clé via le catalogue de la locale, avec repli sur la locale de fallback puis sur la clé elle-même.
  • load_catalog(locale, translations_dir) : charge et valide un catalogue translations/<locale>.json (objet JSON de chaînes), mis en cache.
  • clear_translation_cache() : vide le cache des catalogues.
  • get_default_locale / set_default_locale, get_fallback_locale / set_fallback_locale : pilotent la configuration du noyau (i18n_default_locale, i18n_fallback_locale).
  • Exceptions : I18nError, TranslationCatalogError.

Quand le paquet est installé, le renderer Jinja du noyau expose automatiquement trans() comme fonction globale des templates.

Installation

pip install --pre forge-mvc-i18n

Configuration

Les locales par défaut et de fallback sont des clés du noyau, configurables au démarrage :

import core.forge as forge

forge.configure(i18n_default_locale="fr", i18n_fallback_locale="en")

Exemple

from forge_mvc_i18n import trans

# translations/fr.json -> {"common.save": "Enregistrer"}
trans("common.save")            # "Enregistrer"
trans("inconnu")                # "inconnu" (repli sur la clé)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

forge_mvc_i18n-1.0.0b17.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

forge_mvc_i18n-1.0.0b17-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file forge_mvc_i18n-1.0.0b17.tar.gz.

File metadata

  • Download URL: forge_mvc_i18n-1.0.0b17.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for forge_mvc_i18n-1.0.0b17.tar.gz
Algorithm Hash digest
SHA256 a4268ef140452f564085559d886cc5c311b5884382e32654953b7ee00d1f7b99
MD5 3d4364d8c429af458147de745330308a
BLAKE2b-256 d783b66264848b84795f2cff6b3d57b2f78dc00328d3c40055e0bb6282d9bd41

See more details on using hashes here.

File details

Details for the file forge_mvc_i18n-1.0.0b17-py3-none-any.whl.

File metadata

File hashes

Hashes for forge_mvc_i18n-1.0.0b17-py3-none-any.whl
Algorithm Hash digest
SHA256 26a5a39b5fd3c85bbaefdef70b85b8940ad89bca59c4937cedab0da14d918e6e
MD5 f956e5fb86b7b465c00fd826207fb4fe
BLAKE2b-256 c0f65cf570fc6f3df9e69b455f245da5f34085923acbf6b8f8aff1c52ce92ab0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page