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.

Transaltion always fallback to default

See original GitHub issue

Hello and thank you again for the great work you are doing, i was trying to work on translation in themeProvider for some of my components , since there is no example in stories for translation i tried using docs ,


import ThemeProvider from "@kiwicom/orbit-components/lib/ThemeProvider";
import fr_Fr from "@kiwicom/orbit-components/lib/data/dictionary/fr-FR.json";
       
<ThemeProvider theme={{orbit: customTokens, transitions: true}} dictionary={fr_FR} className="app">
 <div><Translate tKey="breadcrumbs_back" /></div>
</ThemeProvider>

it always print english text , i tried also with custom object inside themeProvider as in docs but still always refering to default language file,

Thank you

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
silvenoncommented, Jul 27, 2020

Hey @kouloughli-hemza 👋 The problem is mixing imports from @kiwicom/orbit-components and @kiwicom/orbit-components/lib/*. webpack supports ES modules, so when you import from @kiwicom/orbit-components, webpack automatically uses our ES build, but when you import from @kiwicom/orbit-components/lib/ThemeProvider, that ThemeProvider is from our CommonJS build.

The solution is simply to import ThemeProvider like this:

import { ThemeProvider } from "@kiwicom/orbit-components"

and make sure you always import from that source, it’s an all-or-nothing kind of thing.

In your case the problem is that CJS ThemeProvider and ES ThemeProvider are two different components. You’re setting the context with CJS ThemeProvider, but your ES Translate component is reading context from ES ThemeProvider, and because that context isn’t being set, it defaults to English.

Let us know if it’s clear now 😉

0reactions
kouloughli-hemzacommented, Jul 13, 2020

You’re right @kouloughli-hemza . It seems that there’s some problem. We’ll check it and give you more info – there should be no difference in the behavior.

Thank You ,

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fallback - i18next documentation
i18next by default loads its translations from one file named translation . However, you can configure it to load from multiple files, called...
Read more >
Fallback to default language when node not translated to ...
The default language is English. Mostly, the author will be translating the articles to Japanese and sometimes no translation.
Read more >
[Translation] Add support for default fallback #35466 - GitHub
First, I'm not an expert on this component, so I will talk here as a user of this component. Description In my application,...
Read more >
Avoid I18n Fallback to default locale - ruby on rails
My default locale is set to :at (Austria). Which I require for Route Translation. Rails server won't start without it and to be...
Read more >
Unpublished translations should fallback to the original ...
If you have an node 1 that has 2 translations, EN is the default language and published, DE is not published. If you...
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