Yii Framework Forum: multilingual site with language code at the beginning of routes - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

multilingual site with language code at the beginning of routes Rate Topic: -----

#1 User is offline   pippo30 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 50
  • Joined: 25-October 13

Posted 02 November 2017 - 07:05 AM

Hi everyone,

I've searched, without success unfortunately.

I have a yii 1.1.14 website that needs to be extended in other languages. I would to know if is possible to have routes like:

- mydomain.com/en/...
- mydomain.com/de/...
- mydomain.com/fr/...

Anyone knows some extensions or whatsoever integration?

Thanks a lot
0

#2 User is offline   Arockia Johnson SR 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 185
  • Joined: 25-June 13
  • Location:Singapore

Posted 09 November 2017 - 04:40 AM

Hi,

You may use a param instead of the route!

Yourdomain.com/lang/en and do the lang key store it into session.

Example code but this is for yii2.x -> this code will be at the bootstrapping event of the web application

$currentLang = \Yii::$app->request->get('lang');
        if (!empty($currentLang)) {
            \Yii::$app->session->set('language', $currentLang);
        }
        $lang = \Yii::$app->session->get('language');
        if (empty($lang)) {
            \Yii::$app->session->set('language', 'en');
        }
        \Yii::$app->language = \Yii::$app->session->get('language');
        return true;



I hope this may help you!
மகிழ்ச்சியாக குறியிடுங்கள்!..... Happy Coding!.....


Thanks & Regards,
ஜான்சன் ( Arockia Johnson SR )
www.arojohnson.tk

Hit (+) button If my replies really helped you!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users