bcit-ci / CodeIgniter

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
18.26k stars 7.6k forks source link

codeigniter Internationalization (i18n) for CodeIgniter 2.x + CI-Smarty #2994

Closed uilson closed 10 years ago

uilson commented 10 years ago

I'm developing a Codeigniter application that requires internationalization (i18n) support.

I'm using CI-Smarty (Smarty 3) as a template solution, and Internationalization (i18n) for CodeIgniter 2.x, but I cant get the multilingual support to work with CI Smarty, I've tried to change the code, tried adding routes, and doing both at the same time but without success.

My site controller:

public function index() {
    $this->news();
 } #index

 public function news() {
    $xml = $this->pages->news();
    $data['news'] = $xml->xpath('//item');
    $data['date'] = $xml->xpath('//item/pubDate');
    $data['alphabet'] = $this->pages->alphabet();
    $data['numbers'] = $this->pages->numbers();
    $data['pagetitle'] = $this->config->item('news_pagetitle');
    $data['description'] = $this->config->item('news_description');
    $data['keywords'] = $this->config->item('news_keywords');
    $this->pages->page('news', $data);
 } #news

My pages model:

function page($page, $data = NULL) {
     $data['base'] = base_url();
     $data['current'] = current_url();
     $data['page'] = $page;
     $data['title'] = $this->config->item('title');
     $data['tagline'] = $this->config->item('tagline');
     $data['datetime'] = date('l, F d, Y');
     $data['dateshow'] = date('Y-n-j');
     $this->parser->parse('header', $data);
     $this->parser->parse($page, $data);
     $this->parser->parse('footer', $data);
 } #page

My routes.php:

$route['^(en|pt)/(.+)$'] = "$2";
 // '/en', '/de', '/fr' and '/nl' URIs -> use default controller
$route['^(en|pt)$'] = $route['default_controller'];

// Prettify the url

$route['default_controller'] = 'site';
$route['404_override'] = 'site/e404';
$route['scaffolding_trigger']= "";

$route['(:any)'] = 'site/$1';
$route['guide/(:num)'] = 'guide/$1';
$route['shows/(:any)'] = 'shows/$1';
$route['shows/(:any)/(:num)'] = 'shows/$1/cat/$2';
$route['title/(:num)/(:any)'] = 'title/$1';

When I request the index page using the www.example.com/en/ which will show the news info and it loads fine, but if I request the page news using www.example.com/en/news it does not load the news, and instead loads the 404 page, and do the same to all other pages.

The application works fine without the internationalization (i18n) support, loading all the pages ok, including the news page.

And also the internationalization (i18n) support works fine, I've tested it in a version without the CI-Smarty.

I need to translate this app into multiple languages, so I need to find a way for Codeigniter with CI-Smarty to support it. Is there one? Thanks to all those how can help.

aanbar commented 10 years ago

You're posting in the wrong place asking for help,

This is for Framework bugs, features requests ...etc.

You should be trying [stackoverflow.com] for this

ivantcholakov commented 10 years ago

@uilson

Yes, it is a wrong place for such a request. Anyway, I would leave a note. I wonder how "Internationalization (i18n) for CodeIgniter 2.x" is affected by Smarty, probably it isn't.

I have searched for a good internationalization solution, but without success. So, I took the library you have mentioned and rewrote it beyond recognition to achieve what I wanted. The original is a very simple and it needs tweaking a lot.