Skip to content

Internationalization (i18n)

grid-view-spec is host-agnostic: UI chrome uses dotted msgids (column_settings.title, export.pdf, …) in Django templates and the JS catalog.

Requirements

  1. Add grid_view_spec.backends.django to INSTALLED_APPS (loads grid_view_spec/locale/).
  2. Set LANGUAGE_CODE and enable LocaleMiddleware in the host project.
  3. Include {% grid_view_spec_assets part='js' force_core=True %} once per page (injects GridViewI18n before bundle scripts).

Optional host overrides: add the same msgids under the host LOCALE_PATHS.

Two surfaces, one catalog

Surface Pattern Example
Django templates {% translate "column_settings.title" %} Modal shell, export buttons, filter bar
JavaScript window.GridViewI18n via GridView.i18n.t(key, fallback) Dynamic modal groups, multiselect labels

All JS keys are listed in grid_view_spec.backends.django.i18n.JS_I18N_KEYS (canonical list in grid_view_spec.i18n) and compiled into locale/*/LC_MESSAGES/django.po.

After editing .po files:

django-admin compilemessages -l en -l uk

Host-owned labels

Table/chart/KPI column labels and filter option text come from the host app (GridViewSpec blocks, filter schemas). Use plain str for export column labels in builders.

Package i18n covers grid chrome only (toolbars, modals, export buttons, empty states).

Column settings + export

Column settings UI uses the same msgids as the modal. Export column order/visibility uses the export_cols URL param — Server filtering.

Do not

  • Hardcode locale-specific strings in package templates or JS.
  • Use English sentence msgids for new strings — prefer dotted keys in grid_view_spec/i18n.py.
  • Use gettext_lazy on exported table column labels in XLSX/PDF builders.