How to use Translation outside a React component?
See original GitHub issueHi, I’m trying to add translation to a object that is outside a React Component, is this possible?
Current code
import React from 'react'
import { useTranslation } from 'react-i18next'
import { Dimmer, Loader, Segment, Item } from 'semantic-ui-react'
import i18next from 'i18next';
// Images
import BankidImage from '../../../assets/img/bankid-logo.png' // Images
import SwishImage from '../../../assets/img/swish.webp' // Images
const webdata = {
bankid: {
image: BankidImage,
textStarted: i18next.t('DimmerBankid.text'),
textComplete: i18next.t('DimmerBankid.complete')
},
swish: {
image: SwishImage,
textStarted:
'Öppna Swish-appen för att slutföra transaktionen. Kontrollera belopp, mottagare och acceptera betalningen. Klart!',
textComplete: 'Betalning är genomförd. Tack!'
}
}
export function DimmerLoading({ active, type, action }) {
return (
<Dimmer active={active} inverted>
<Loader inverted>
<Segment>
<Item.Group>
<Item>
<Item.Image size="tiny" src={webdata[type].image} />
<Item.Content verticalAlign="middle">
{action ? webdata[type].textComplete : webdata[type].textStarted}
</Item.Content>
</Item>
</Item.Group>
</Segment>
</Loader>
</Dimmer>
)
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Translation outside React Component · Issue #909 - GitHub
Outside of react components just use the i18next instance: import i18n from `./i18n` i18n.t( ...
Read more >i18next translation outside component - Stack Overflow
I'm using create-react-app and it's default settings for folders reference, maybe this is the key problem, but I can't find out why and...
Read more >Step by step guide - react-i18next documentation
The Trans component is the best way to translate a JSX tree in one translation. This enables you to eg. easily translate text...
Read more >How to use Translation outside a React component?
Hi, I'm trying to add translation to a object that is outside a React Component, is this possible? Current code import React from...
Read more >Common i18n patterns in React — LinguiJS documentation
Using jsx macros is the most straightforward way how to translate your React components. <Trans> handles translations of messages including variables and other ......
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 Free
Top 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
Something like:
Just like that: