XF 2.0 Get phrase for different languages

Lukas W.

Well-known member
I have a language entity given and want to obtain a specific phrase in that language. What would be the best approach to do so?
 
Last edited:
PHP:
\XF::app()->language($languageId)->phrase($name, $params, true, true);
First true is to control pre-loading, second true is to control whether HTML is allowed. These both default to true for normal phrase calls via \XF::phrase().
 
Thanks. I assume this will do the normal phrase inheritance? Is there also a way to obtain the phrase only if it is set for that specific language or would it be best to use the finder-system for that?
 
Yeah it should return the effective phrase in that language (which might be a version of the phrase from a parent language).

If you care about whether the phrase actually exists in the language specifically or not then, yeah, finding via the Finder system would probably be the way to go.
 
Back
Top Bottom