Difference between #29 and #30 of
How to have truly multilingual URLs

Revision #30 has been created by oligalma on Dec 12, 2021, 8:33:25 AM with the memo:

Demo links
« previous (#29) next (#31) »

Changes

Title unchanged

How to have truly multilingual URLs

Category unchanged

How-tos

Yii version changed

1.1

Tags changed

URL,multiliangual, ge,multilainguage, url, multilingual url, multilanguage url

Content changed

Introduction ------------------ We can easily have a multilingual site if we put a "lang" parameter that comes via GET. For example:
```php

<?php
echo CHtml::link('Tutorials', array('/site/tutorials', 'lang' => 'en'));
[...]
Then, in Controller.php, we need to put this piece of code:


```php

public function beforeAction($action)
{
[...]
Finally we can add the following rules:


```php

'urlManager'=>array(
'urlFormat'=>'path',
[...]
This leads to URLs like these:

-
http://www.oligalma.com/en/tutorials downloads (English) - http://www.oligalma.com/es/tutorials  (Spanish)
 
- http://www.oligalma.com/en/services  (English)
 
- http://www.oligalma.com/es/services 
downloads (Spanish)
 
This is fine to have a multilingual site. But, we can go one step further. What if we want URLs like these: - http://www.oligalma.com/en/tutorialdownloads (English) - http://www.oligalma.com/es/tutoriales (Spanish)
 
- http://www.oligalma.com/en/services (English)
 
- http://www.oligalma.com/es/servicio
descargas (Spanish)

That is, every URL has its particular path. It changes the whole URL, not just the two initial letters (en/es).
[...]
------------


```php

'urlManager'=>array(
'matchValue'=>true,
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
[...]
0 0
3 followers
Viewed: 18 022 times
Version: 1.1
Category: How-tos
Written by: oligalma
Last updated by: oligalma
Created on: Sep 29, 2015
Last updated: 3 years ago
Update Article

Revisions

View all history