FilterDropdown: translate when the host has i18n, never require it
Some checks are pending
build-gate / build (push) Waiting to run
Some checks are pending
build-gate / build (push) Waiting to run
db36397b made the dropdown call useI18n() unconditionally. That throws
"Need to install with `app.use` function" on any host that never
installed vue-i18n, and people-groups-grid deliberately doesn't (its
labels come through its `t` prop). The grid rendered 2 DOM nodes and a
page error: standalone, in the plugin studio, and inside every
composite that nests it (research-map-plus-grid, stack-demo).
The dropdown now uses the host's translations when it has them and the
English strings otherwise. Verified: people-groups-grid renders with no
error again, and region-dashboards in French still shows "Aucune option
trouvée".
This commit is contained in:
parent
e32034039d
commit
6603dc176b
1 changed files with 9 additions and 1 deletions
|
|
@ -38,7 +38,15 @@ const props = defineProps({
|
||||||
// two visible strings — the clear button and the empty state — were English literals, and one of
|
// two visible strings — the clear button and the empty state — were English literals, and one of
|
||||||
// them ('No options found') was ALREADY catalogued in eleven locales elsewhere in this repo, so
|
// them ('No options found') was ALREADY catalogued in eleven locales elsewhere in this repo, so
|
||||||
// the translation existed and this component was ignoring it.
|
// the translation existed and this component was ignoring it.
|
||||||
const { t } = useI18n()
|
//
|
||||||
|
// ★ i18n IS OPTIONAL HERE, NOT REQUIRED. useI18n() THROWS ("Need to install with `app.use`
|
||||||
|
// function") when the host element never installed vue-i18n — and people-groups-grid deliberately
|
||||||
|
// doesn't (its labels arrive through its `t` prop). The unguarded call blanked the grid standalone,
|
||||||
|
// in the studio and inside every composite that nests it (measured 2026-09-25: 2 DOM nodes, page
|
||||||
|
// error on mount). Use the host's translations when it has them, English otherwise.
|
||||||
|
const FALLBACK = { 'buttons.clearSelection': 'Clear selection', 'buttons.noOptions': 'No options found' }
|
||||||
|
let t = (key) => FALLBACK[key] || key
|
||||||
|
try { t = useI18n().t } catch (_) { /* no i18n on this host: keep the English fallback */ }
|
||||||
|
|
||||||
const emit = defineEmits(['filter-change', 'filter-clear'])
|
const emit = defineEmits(['filter-change', 'filter-clear'])
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue