CodeIgniter Forums

Full Version: Help needed with generating and translating urls
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
HI!
I'm working with uri language identifier. I don't see option how to translate url/contoller also.

So let say i have two languages (en, si).
This is how i generate urls currently and language switching works ok


PHP Code:
<a href="<?php echo base_url(lang('contact')); ?>">Contact</a


My language files contains those lines.
Code:
$lang['contact'] = "contact";
$lang['contact'] = "kontakt";

My routs
Code:
$route['default_controller'] = 'home';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

//route example: http://domain.tld/en/controller => http://domain.tld/controller
$route['(\w{2})/(.*)'] = '$2';
$route['(\w{2})'] = $route['default_controller'];

my config file
Code:
$config['language'] = 'english';
$config['language_abbr'] = "en";
$config['lang_uri_abbr'] = array("en" => "english", "si" => "slovenian");
$config['lang_ignore'] = false;

How to generate url properly and how to translate them?
I'm using CodeIgniter 3.0.5

Thank you in advance!
Regards,
Davor