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

Check if translations exists #1588

Closed
m4rc1nn opened this issue Dec 2, 2024 · 4 comments
Closed

Check if translations exists #1588

m4rc1nn opened this issue Dec 2, 2024 · 4 comments
Labels
enhancement New feature or request unconfirmed Needs triage.

Comments

@m4rc1nn
Copy link

m4rc1nn commented Dec 2, 2024

Is your feature request related to a problem? Please describe.

Currently i have to use code like this to check if translations exists
{__("small-text") !==${translations}.small-text&& ( <div className="mb-6 text-center font-bold"> {__("small-text")} </div> )}

and this throw an error MISSING_MESSAGES and i have to pass onError function to provider.

Can we add some function e.g: t.has()?

Describe the solution you'd like

add function to check if translations exists
t.has();

Describe alternatives you've considered

add function to check if translations exists
t.has();

@m4rc1nn m4rc1nn added enhancement New feature or request unconfirmed Needs triage. labels Dec 2, 2024
@amannn
Copy link
Owner

amannn commented Dec 3, 2024

@m4rc1nn
Copy link
Author

m4rc1nn commented Dec 3, 2024

@amannn No in the docs, but i already tried this in my code and get an error:
Screenshot 2024-12-03 at 09 35 38

I'm using [email protected] and [email protected]

@amannn
Copy link
Owner

amannn commented Dec 3, 2024

t.has was added in v.3.21. If you upgrade, you can use it.

@m4rc1nn
Copy link
Author

m4rc1nn commented Dec 3, 2024

@amannn Thanks a lot!

@m4rc1nn m4rc1nn closed this as completed Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request unconfirmed Needs triage.
Projects
None yet
Development

No branches or pull requests

2 participants