Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React i18n, check if translation exists?

Is there a way to check if a locale exists on react app ? Like a boolean true/false

like image 869
Panayiotis Georgiou Avatar asked Dec 27 '25 14:12

Panayiotis Georgiou


1 Answers

Yes, you can check if your language variable exists with i18n.exists() method:

You can extract i18n from useTranslation hook.

const { t, i18n } = useTranslation();

Then call i18n.exists('my.key'), for example:

i18n.exists("common.values.active")

https://www.i18next.com/overview/api#exists

like image 82
Dilara Aksoy Avatar answered Dec 31 '25 17:12

Dilara Aksoy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!