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.0b16.tar.gz (4.4 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.0b16-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: forge_mvc_i18n-1.0.0b16.tar.gz
  • Upload date:
  • Size: 4.4 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.0b16.tar.gz
Algorithm Hash digest
SHA256 f02f7da12189d8b44753e5305cf617b27559f049f5fdba6d5e77550118f13758
MD5 ce9c98993f3d118814c3949142a09d44
BLAKE2b-256 cc40dc5afc2cee39e098070d6734fa5ee482eda97d82f6b3bb2e9bdba897f7b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for forge_mvc_i18n-1.0.0b16-py3-none-any.whl
Algorithm Hash digest
SHA256 39e8997a8da24329b8f7cff4469e032b58b7feb0208cc9b3a2f6e65f5f74b4aa
MD5 e6a61441b7ec3c7b6720a3297955dfcb
BLAKE2b-256 374eedde3376ed31013953cc872f78a7dd62f87eb1f1b5ae64667f53fe701b49

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