• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 2.0 Get phrase for different languages

katsulynx

Well-known member
#1
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:

Chris D

XenForo developer
Staff member
#2
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().
 

katsulynx

Well-known member
#3
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?
 

Chris D

XenForo developer
Staff member
#4
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.