How do I access current language outside setup? (Especially from a plugin!)
- Dominant language
- TypeScript
- Stars
- 204
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
Right now, I'm trying to build a plugin to do something depending on current language, so I need to get access to what current language is.
so, the idea that comes up on my mind now is to get useI18n().locale;
but it doesn't work leading to this error "Must be called at the top of a `setup` function"
Any help would be very appreciated !
Contributor guide
Research direction
Start by reproducing the useI18n().locale call from the plugin context described in the issue, then inspect the Nuxt 3 plugin entry point and how the current language is exposed there. Done means identifying and documenting a supported way for a plugin to access the current language without violating the setup constraint.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- internationalization
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100