Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trans component defaultValue not working for empty string #193

Open
Peter554 opened this issue Aug 27, 2020 · 0 comments
Open

Trans component defaultValue not working for empty string #193

Peter554 opened this issue Aug 27, 2020 · 0 comments

Comments

@Peter554
Copy link

Peter554 commented Aug 27, 2020

🐛 Bug Report

The Trans component defaultValue is not working for an empty string. Both for a string and for a function returning a string.

defaultValue: ""
// or
defaultValue: (lng, ns, key, options) => ""

That's important for me as I have a use case

defaultValue: (lng, ns, key, options) => lng === "foo" ? key : ""

To Reproduce

See these tests added on my fork - Peter554@de803c5.

When I run the tests they fail:

--- expected                                                                                                           
  +++ actual                                                                                                             
  @@ -1,3 +1,3 @@                                                                                                        
   Object {                                                                                                              
  -  "Trans component should respect the defaultValue option": "",                                                       
  +  "Trans component should respect the defaultValue option": "Trans component should respect the defaultValue option", 
   }

You can also see the tests failing here - #194 - running in your CI (I made a draft PR to demonstrate).

Expected behavior

I expect the tests to pass.

Your Environment

  • runtime version: node v10.19.0
  • i18next version: 19.7.0
  • os: Linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant