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

this.$t is undefined in Quasar 2 #9010

Closed
alexanderdeabreuwannme opened this issue Apr 23, 2021 · 4 comments
Closed

this.$t is undefined in Quasar 2 #9010

alexanderdeabreuwannme opened this issue Apr 23, 2021 · 4 comments

Comments

@alexanderdeabreuwannme
Copy link

alexanderdeabreuwannme commented Apr 23, 2021

Currently I have Quasar 2 installed in a project and when I try to access this.$t for example for the i18n, I get an error saying that it is undefined.

UPDATE: I have seen what the error is, I am trying to access this.$t, currently I see that this is not supported, what would be your alternative? and if I want to use for example this.$q from Quasar I should do: import { useQuasar } from 'quasar' but... what would be the equivalent of $t for i18n?

@alexanderdeabreuwannme alexanderdeabreuwannme changed the title this.$q is undefined in Quasar 2 this.$t is undefined in Quasar 2 Apr 23, 2021
@ThibaultJousse
Copy link

ThibaultJousse commented Apr 23, 2021

I'm guessing you're trying to use this in setup(), where it is undefined : see https://v3.vuejs.org/guide/composition-api-setup.html

you have to import useI18n first :

import { useI18n } from "vue-i18n";

then you can access $t (without this prefix) in setup() this way :

const { t: $t } = useI18n();

@rstoenescu
Copy link
Member

Always read the documentation of the packages that you are using. In this case, the docs for vue-i18n should state how it can be used with Composition API.

@tmikaeld
Copy link

tmikaeld commented Nov 7, 2021

@rstoenescu Still, should update the Quasar docs on how to use it, since this is where people check first. And it doesn't mention the composable API, but it's mentioned on most other places.

@rstoenescu
Copy link
Member

@tmikaeld There you go. Improved docs. Will be available in next docs deployment.
Took the opportunity to also PR the vue-i18n docs with references to Quasar CLI usage :)

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

No branches or pull requests

4 participants