Answer the question
In order to leave comments, you need to log in
How to put a condition to determine the current language?
Multilanguage for the site is configured. Language switching works.
But you need to put certain content (text, picture, scripts) for one of the languages on one of the pages.
Tried
<?php
if ($lang === Yii::app()->params['en']) {
echo 'hello';
} else {
echo 'bye';
}
?>
Answer the question
In order to leave comments, you need to log in
If multilingualism is done correctly, then the current language should be in Yii::app()->language (where it comes from - it all depends on your implementation - at least from a cookie, session, or even from a URI). And then check exactly this value.
if (Yii::app()->language === $someLanguageCode) {
echo 'hello';
} else {
echo 'bye';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question