Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add i18n in context #1112

Closed
ArthurDanjou opened this issue Mar 16, 2021 · 3 comments · Fixed by #1120
Closed

Add i18n in context #1112

ArthurDanjou opened this issue Mar 16, 2021 · 3 comments · Fixed by #1120

Comments

@ArthurDanjou
Copy link

Is your feature request related to a problem? Please describe.

I recently discovered a new feature of View 3: The Composition API. So I learned about the existence of the Nuxt Composition API module. So I want to adapt my current site with this functionality, however the i18n module is not yet compatible.

Describe the solution you'd like

I wanted to access the i18n module inside the context method.

Describe alternatives you've considered

Actually, I have added the type inside the 'index.d.ts' file to access the i18n module directly from the context but I dont know if it is the best way

Additional context

https://codesandbox.io/s/github/ArthurDanjou/artsite/tree/dev for testing and seeing what i have test

@rchl
Copy link
Collaborator

rchl commented Mar 16, 2021

Should work with @nuxtjs/composition-api. See a working example here https://github.com/nuxt-community/i18n-module/blob/master/test/fixture/composition-api/pages/index.vue

@ArthurDanjou
Copy link
Author

Bonjour, merci pour la reponse. Cependant, j'ai vu avec @pi0 qui m'a demande d'ouvrir un ticket pour l'ajouter directement dans le context

@rchl rchl changed the title Add i18n in context for @nuxt/composition-api Add i18n in context Mar 17, 2021
@rchl
Copy link
Collaborator

rchl commented Mar 17, 2021

Can do that but that's not specific to composition API so updated the title.

BTW. Currently nuxt-i18n injects those to context.app:

  • i18n
  • localePath
  • localeRoute
  • switchLocalePath
  • getRouteBaseName

So I'm not entirely sure if I should expose all of those in context or just i18n. For consistency, the former would make more sense.

rchl added a commit that referenced this issue Mar 24, 2021
The APIs that were exposed on `context.app`, like:
 - `i18n`
 - `getRouteBaseName`
 - `localePath`
 - `localeRoute`
 - `switchLocalePath`

 are now also exposed directly on `context`.

Resolves #1112
rchl added a commit that referenced this issue Mar 24, 2021
The APIs that were exposed on `context.app`, like:
 - `i18n`
 - `getRouteBaseName`
 - `localePath`
 - `localeRoute`
 - `switchLocalePath`

 are now also exposed directly on `context`.

Resolves #1112
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants