i18n — Aquilia Documentation
Comprehensive guide and documentation for i18n in the Aquilia framework. View API reference, examples, and implementation patterns.
Advanced / i18n Internationalization (i18n) Aquilia i18n is an async-native localization subsystem with locale negotiation, plural-aware translation lookup, flexible catalog backends, and first-class integration into middleware, templates, DI containers, and CLI workflows. What You Get ))} Workspace-Level Integration Initialize i18n globally in your workspace configuration. You can configure available locales, directory paths, catalog formats, and the locale resolver preference chain. from aquilia import Workspace from aquilia.integrations.i18n import I18nIntegration workspace = ( Workspace("localized-app") .integrate(I18nIntegration( default_locale="en", available_locales=["en", "es", "fr", "ja"], catalog_dirs=["locales"], resolver_order=["query", "cookie", "header"], )) ) Manifest & Module Integration Controllers and services declared in the AppManifest can request the I18nService via constructor dependency injection. You can also define module-level constants using lazy translation utilities. from aquilia import Controller, GET, RequestCtx from aquilia.i18n import I18nService, lazy_t # Constant resolved lazily when the request locale is available BILLING_HEADER = lazy_t("billing.invoice_header") class BillingController(Controller): def __init__(self, i18n: I18nService): self.i18n = i18n @GET("/invoice") async def get_invoice(self, ctx: RequestCtx): locale = ctx.request.state.get("locale", "en") message = self.i18n.t( "billing.invoice_ready", locale=locale, amount="$45.00" ) return Request State Contract State Key Type Meaning locale str Resolved BCP 47 locale tag after negotiating candidate headers/cookies. locale_obj Locale Parsed Locale model with validation, normalization, and fallback properties. i18n I18nService Primary translation and formatting service registry bound to the active request context. Documentation Map ))} )
Go to Homepage