Check If Translated Message Exists


Is there an easy way to check if a translated message exists without using missing events ?

I want something like that

if (Yii::t('category','message')=='message') translation exists 

But the above code is little tricky

Anyone please?

I think the suggested code is a little buggy. There are plenty of languages that share words, so you might get errors where a translation exists. A contrived example is the translation of English "correct" into French would yield the same word, and hence give an error.

I’m not sure what the best solution is, but you should probably create your own helper function to handle translation, deal with the missing events and return false (or null). You could then write something like:

if (Tr::t('category','message') === false) // translation exists