question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trans Component namespace

See original GitHub issue

Describe the bug When using Trans component in conjunction with useTranslation hook namespace set in hook is not used for translation inside component.

const [t] = useTranslation('ns');
<Trans t={t} i18nKey="some.key">
Placeholder
</Trans>

Deducting from debug info Trans component use translation namespace instead of ns. When I explicitly specify namespace in key it works as intended (<Trans i18nKey="ns:some.key">...) as well as when namespace is declared through ns="ns" prop, but from what I can remember using t namespace worked before.

Occurs in react-i18next version v10.11.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
jamuhlcommented, Jun 16, 2019

@kachkaev should be fixed in react-i18next@10.11.1

1reaction
jamuhlcommented, Jul 23, 2019

It fixes by taking the passed in t function … not by magically pass the one from withTranslation to the Trans component.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trans Component - react-i18next documentation
transSupportBasicHtmlNodes · true · Enables keeping the name of simple nodes (e.g. <br/> ) in translations instead of indexed keys.
Read more >
Developer's guide to internationalization
Step by step how to internationalize your i18n component ... Note: Please provide the current namespace to Trans component by passing ns="currentModule" and ......
Read more >
A Guide to React Localization with i18next | Phrase
We're using the default, translation , namespace here. If we were to load our app at this point, we would get an error...
Read more >
How to use the Trans component for bold or italicized text in ...
Solved the issue. The problem is that I wasn't passing in the namespace of my translation file correctly to the Trans component.
Read more >
i18next-scanner - npm
defaultNs. Type: String Default: 'translation'. The default namespace used if not passed to translation function. defaultValue.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found