PHP code example of leinonen / yii2-hostname-language

1. Go to this page and download the library: Download leinonen/yii2-hostname-language library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

leinonen / yii2-hostname-language example snippets


use leinonen\HostnameLanguage\LanguageSelector;

'bootstrap' => ['hostLanguage'],
'components' => [
    'hostLanguage' => [
        'class' => LanguageSelector::class,
        'hosts' => [
             'example.com' => 'fi-FI',
             'foobar.se' => 'se-SE',
      ]
    ]
],


use leinonen\HostnameLanguage\UrlManager;

'components' => [
    'urlManager' => [ 
      'class' => UrlManager::class,
      'enablePrettyUrl' => true,
      'showScriptName' => false,
    ]
]   

Url::to(['site/my-route', 'language' => 'en-US'], true);

'urlManager' => [ 
    ...
    'languageParam' => 'lang'
]
 
Url::to(['site/my-route', 'lang' => 'en-US'], true);