Localeurls

If you want to have the application language in your URLs like





/en/some/page

/de/some/page

http://www.example.com/en/some/page

http://www.example.com/de/some/page



then it has never been easier: Check out this new extension which does the dirty work for you.

http://www.yiiframework.com/extension/localeurls/

It’s quick and easy to install, does not require any extra URL rules, creates language URLs transparently, supports a default language and persists the current language selection in session and a cookie.

And what about URLs with name of action in current language?

website.com/aboutus but in german website.com/uberuns?

and also for example I have forum programmed in Yii. How I can have URL website.com/forum/5/article-name-is-good-here-for-seo ?

Thanks

That’s a different story :). You’ll need a custom URL rule for this case anyway because how should an extension know, how you want to translate your page names?

This extension is only for applications where the URLs use the above patterns.

[/size]

You can achieve that with regular URL rules or with a custom URL rule class. Please read the guide on this topic:

http://www.yiiframework.com/doc/guide/1.1/en/topics.url

Maybe from translations file :) I don’t know I am just asking if somebody done this before.

Thanks for your answers.

Updated the extension to 1.1.0: Handling of the default language has been improved. Default is now, whatever you configure in your main app config. You can decide if you want a redirect from www.example.com to www.example.com/en (if en is your default), by setting redirectDefault. Default is false.

And yet another update (1.1.2): The extension now by default tries to auto detect the preferred user language from the HTTP headers (using CHttpRequest::preferredLanguages). It can be disabled through ‘detectLanguage’ => false.

New Version 1.1.3: You can now map URL names to languages. So e.g. http://example.com/english/some/page can be mapped to language ‘en’.

Find the full docs here.

New Version 1.1.4: Fix an issue where you could not create links to reset to default language.

New Version 1.1.5: Fix an issue where the query string ("?a=b") was lost, when you tried to switch to default language.