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.

Missing translation on React Native. Yup doesn't work properly with i18n

See original GitHub issue

I have this piece of a code. I want to add error messages depending on user’s locale, but yup throws errors, same if fields are filled in incorrectly

[missing “en.login.emailRequiredError” translation] [missing “en.login.passRequiredError” translation]

const schema = yup.object().shape({ email: yup .string() .email(i18n.t('login.emailSpellError')) .required(i18n.t('login.emailRequiredError')), password: yup .string() .matches(/^((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,15})$/i, i18n.t('login.passSpellError')) .required(i18n.t('login.passRequiredError')), });

i18n.t(‘login.passRequiredError’) works fine when I put it into a render method for checking it but it does not work with the yup. Any suggestions? Thanks in advance

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
olejka91commented, Mar 20, 2018

Thanks, I found out the issue, it was a wrong place of i18n initialization. My bad

1reaction
jquensecommented, Mar 20, 2018

Maybe they don’t exist when yup schema is created, i’m not sure. The error you’ve posted though is not a Yup, one it’s being thrown by your code. There isn’t much I can do unfortunately, i’d suggest walking through the code with the debugger and seeing where it breaks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Yup doesn't work properly with i18n - Stack Overflow
The goal here is to move the t() method into your render method and have all translations happen there. Share.
Read more >
Internationalization - React Made Native Easy
It integrates i18n.js with React Native and uses the user preferred locale ... for the testers/devs to know if a translation is missing...
Read more >
Tutorial - Internationalization of React apps - LinguiJS - JS.ORG
Through this tutorial, we'll learn how to add internationalization (i18n) to an existing application in React JS. Let's Start¶. We're going to translate...
Read more >
The complete guide to internationalization in Next.js
Learn how to make your Next.js app international with smooth translation features in this advanced, step-by-step tutorial.
Read more >
Fallback - i18next documentation
By default, if a variant (containing region, script, etc) is not found, i18next will look for the same key in the broader version...
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