Skip to content

Support i18n custom blocks when useI18n() is used in Legacy API mode #1020

@matthew-white

Description

@matthew-white

Clear and concise description of the problem

Hi @kazupon! I wanted to thank you for the discussion about using useI18n() with Legacy API mode and local scope, as well as the PR that added that functionality. I just finished converting our codebase to Vue 3, and I've been greatly enjoying Vue I18n v9.

One thing I was wondering was whether it might be possible to add support for i18n custom blocks when using useI18n() in Legacy API mode. When I use useI18n() in a component with an i18n custom block, I see the following error message: "Must define ‘i18n’ option in Composition API with using local scope in Legacy API mode".

Suggested solution

In the code, it looks like useI18nForLegacy() throws this error if local scope is used and no i18n option was specified in the component definition. I believe that when an i18n custom block is defined, there is no i18n option, but there is an __i18n option. Could useI18nForLegacy() bypass that error if there is an __i18n option? I see that later in the function, instance.proxy.$i18n is used; I believe that that should exist when either option is specified, i18n or __i18n.

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions