You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then in a view, I would like to call for an API, sending the current locale of the page.
import{useI18n}from'vue-i18n';const{ locale }=useI18n();constarticle=awaitAPI.getArticle('whatever',locale.value);// That makes typescript complains on locale.value because it's not of type 'en' | 'es'
Everything's working correctly, but I would like to safely check for Locale type in API method. For example in case I want to force calling for a locale. Do you know how can I achieve this?
I know I can made locale.value as 'es' | 'en', but would be amazing if somehow i18n could manage it.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm implementing vue-i18n
9.9.1
in a nuxt 3 app, where I have two locales with it's corresponding setup.That's the i18n implementation:
Then in a view, I would like to call for an API, sending the current locale of the page.
Api method:
Everything's working correctly, but I would like to safely check for Locale type in API method. For example in case I want to force calling for a locale. Do you know how can I achieve this?
I know I can made
locale.value as 'es' | 'en'
, but would be amazing if somehow i18n could manage it.Thank you very much.
Beta Was this translation helpful? Give feedback.
All reactions