N
N
newbieman2015-03-05 11:32:34
Yii
newbieman, 2015-03-05 11:32:34

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

1 answer(s)
V
Vadim Stepanov, 2015-03-13
@Vdm17

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 question

Ask a Question

731 491 924 answers to any question