$t and SFC locales not working in functional components
See original GitHub issuevue & vue-i18n version
Vue: 2.5.13 Vue-i18n : 7.4.2
Steps to reproduce
- Create a project with Vue and Vue-i18n
- Add a locale and some messages
// for example
<i18n>
{
"fr": {
"my_message": "Bonjour"
}
}
- Create a functional component and user $t function or v-t directive
<template functional>
<p>{{ $t('my_message') }} <span v-t="'my_message'"></span></p>
</template>
What is Expected?
I’m excpecting to see “Bonjour Bonjour” in a p and a span tag
What is actually happening?
warnings / errors / only keys are rendered
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to type Stateless Functional Component using styled ...
Typescript says to me that props style does not exist in my type SFC<{}> . Indeed I defined it nowhere. What I tried....
Read more >React Stateless Functional Components: Nine Wins You Might ...
It's a quick way to hack in a feature. Since stateless functional components don't support local state, you can't easily hack in some...
Read more >Functional React Components in TypeScript
But React encourages stateless functional components (SFCs) for simple, presentational components. Let's convert our App component to a TypeScript-driven ...
Read more >How to translate your Vue.js application with vue-i18n
The directory where store localization messages of project. It's stored under src directory: locales; Enable locale messages in Single file components ? y....
Read more >Airbnb React/JSX Style Guide
And if you don't have state or refs, prefer normal functions (not arrow functions) over classes: // bad class Listing extends React.Component {...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m with @darkylmnx for this issue
parent.$t
isn’t optimal because it’s working only if it’s the parent component who have the<i18n>
translation defined in it.This mean if i need to make a simple translation component, i can’t do it functional:
It will not work in two case:
<i18n>
tags)OR
@kimuraz as I said it’s not working for $t and SFC, what you said works for “$t” yes but SFC i18n tag still doesn’t work from what I saw