Skip to content

Make availableLocales reactive #1893

@markusand

Description

@markusand

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

return Object.keys(_messages.value).sort()
to something like the following would do the trick.

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

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions