user4269288
user4269288

Reputation: 109

CodeIgniter: how to translate the URL in the selected language

I'm working on a project with CodeIgniter. I am using the specific language class to show the content in different languages. Now I need to translate the URL in the selected language.

For example: www.domain.com/book/category to www.domain.com/buch/kategorie

How can I do it?

Upvotes: 0

Views: 561

Answers (2)

El Don
El Don

Reputation: 912

You will have to create different controllers showing the same views (that should be translated themselves) then links will make call to relevent controller language.

this will work only if you decide to make your urls like host/lang/something

like www.domain.com/en/book/category to www.domain.com/de/buch/kategorie if your controllers are named en and de

Controllers' and functions' names should be saved in languge files

You can search here on stackoverflow for methods about setting language from cookies or session if are not already doing this

If you find any better suggesstion please share

Upvotes: 0

splash58
splash58

Reputation: 26153

  1. I think, you can use route fo this, as:

    route['buch/kategorie'] = 'book/category';

  2. The second aspect of the problem - the generation of links in different languages for view. You should write some code for this

Upvotes: 2

Related Questions