vue-i18n icon indicating copy to clipboard operation
vue-i18n copied to clipboard

Make availableLocales reactive

Open markusand opened this issue 1 year ago • 2 comments
trafficstars

Clear and concise description of the problem

Using availableLocales in a component is a list of strings that doesn't update reactively when adding new messages.

const { availableLocales } = useI18n();  // string[]

i18n.global.setLocaleMessage('ca', messages); // Does not trigger an update to availableLocales 

Suggested solution

Would be useful if availableLocales was a computed list so any list or selector or whatever that is using it can update automatically

const { availableLocales } = useI18n(); // ComputedRef<string[]>

Not sure if changing line https://github.com/intlify/vue-i18n/blob/e9ab3e0933b8ac9cb859578235b363876065fdf2/packages/vue-i18n-core/src/composer.ts#L2559 to something like the following would do the trick.

return computed(() => Object.keys(_messages.value).sort());

Alternative

No response

Additional context

No response

Validations

markusand avatar Jul 16 '24 09:07 markusand