Using multiple language views for the same controller in CodeIgniter

How do I use multiple language views in a controller according to the url parameter? I have a english version of a website in CodeIgniter.I want to make Greek and Arabic version of this website without changing the models and controllers.Anybody know how to do it so that i can get CodeIgniter to display different views for the same controller according to the language parameters in the URL. like the URL below for English for Arabic for Greek

Thanks in advance


Try with this:

Internationalization (i18n) library for CodeIgniter

I've used it in my project with little modification and it is really great.

You can choose to do the following, if you have different templates/views for each language.

$lang = $this->uri->segment(1);


Then you can store each different languages like this:


Please keep in mind to edit the routes, so you can use the same controller. I would use Regex in the routing system, like this:

$route['([a-z_A-Z]+)/controller'] = 'controller';

Then when you do , you should be redirected to the controller and $this->uri->segment(1); will be available for language selection.

Category:php Time:2010-11-06 Views:0

Related post

  • Dismiss multiple modal views without a navigation controller 2011-05-12

    I didn't plan ahead properly for view navigation in my app, so it's possible for the user to go through a loop that just stacks modal views on top of each other, and from there the root view controller is only accessible through the time-consuming pr

  • Does loading a view effectively stop a controller in CodeIgniter? 2010-07-12

    Would the following code in a controller prevent the nextFunction() from running? $this->load->view('foo'); nextFunction(); --------------Solutions------------- Ostensibly, that seems to be the case. Apparently, CI will combine calls to multipl

  • how do i pass a view variable to the controller in codeigniter? 2011-06-26

    My View :- <html> <?= link_tag(base_url().'css/simple.css'); ?> <body> <?php $this->load->helper('form'); ?> <?php $this->load->view('commentform'); ?> <?php $id=$this->uri->segment(3);?> <?php

  • Is there a way to load inline view snippets from a controller in CodeIgniter? 2011-07-15

    Let's say I have a controller function with these lines: $this->load->view('stdHeader_view'); echo "<div class='main'>"; $this->loadView('foo_view'); echo '</div>'; $this->load->view('stdFooter_view'); This won't do what I

  • Using Multiple Detail Views with Split View Controller 2011-10-02

    As you know, a split view controller has one root controller and one detail view controller only, but I want to use another detail view controller. When I select the list items from the root controller (popover controller), the selection should fire

  • ExtJS 4 MVC multiple instances of views and sub/child controller difficulties 2011-11-28

    I have encountered a problem with the MVC pattern in ExtJS 4. At least, I think I have. Having approached multiple people with this question, and having posted numerous times in the Sencha forums, I am now turning to a broader audience in hopes of ge

  • Codeigniter urls in multiple languages but handled by the same controller 2011-11-29

    Let's say I would like to list products on a codeigniter project and support multiple languages, so that someone would select english and get the url where 5 is the page number, and someone else would select italian and go get

  • How can I move multiple UIImage views around a view controller? 2013-12-14

    How can I move multiple UIImage views around a view controller? I have managed to use this code; -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ printf("touch began --------- |n"); } -(void)touchesMoved:(NSSet *)touches withEvent:(UI

  • How to route a multiple language URL with a MVC framework in PHP? 2009-05-15

    I would do something similar to this in PHP: It's possible? How can I route the controllers / views using multiple languages? I was wondering if it could be possible

  • Is it bad practice to put view code in the controller? 2009-09-01

    In MVC (such as JSP and Spring), is it bad practice to view related code in the controller? In my case, the controller does some work and then hands off the results to the view (JSP). In the case of a status message, I can pass the entire message tex

  • How to support multiple languages on a microcontroller? 2008-09-10

    I'm currently working on upgrading a product for the Chinese market. The target is a ARMTDMI7 with a QVGA display. Most resources I've located on the net are targeted at desktop or web programming rather than embedded devices. Can anyone suggest some

  • Storing content in multiple languages? E.g. English, French, German 2008-09-16

    How should I store (and present) the text on a website intended for worldwide use, with several languages? The content is mostly in the form of 500+ word articles, although I will need to translate tiny snippets of text on each page too (such as "pri

  • Multiple Modal-view Transitions Crash App 2009-07-23

    I would like to present multiple modal views in sequence (e.g. show confirmation page after selecting a picture from image picker). My problem is that the animation of dismissal and presenting in subsequent steps without delay always crashes the app

  • Loading multiple language files in CodeIgniter 2010-01-07

    Can I load multiple language files for the same view in CodeIgniter? --------------Solutions------------- ah... Well it was pretty simple. I just loaded the two files with $this->lang->load(). $this->lang->load("lang_file1"); $this->la

  • How to route a multiple language URL with a MVC 2010-01-27

    I need multi-language URL route of existing controller. Let me explain more: I have a controller with name "Product" and View with name "Software"; therefore, by default if the user enters "", get right content (t

  • In Spring MVC (2.0) how can you easily hook multiple pages/urls to use 1 controller? 2010-04-12

    <!--dispatcher file--> <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <props> <prop key="/foo/bar/baz/boz_a.html">bozController</prop> <

  • mvc 2 multiple partial view 2010-05-07

    I have a contoller that renders 3 different views. But I also have a common part (div) for every view. I thought that I can create an UserControl with own controller and include that control on my views (New controller and view as controll). How shou

  • What is the best way to store multiple language versions of a website? 2010-07-14

    My web site (on Linux servers) needs to support multiple languages. What is the best practice to have/store multiple languages versions of the same site? Some I can think of: store in DB different view file for each language gettex hard coded words i

  • Zend_Form:: When should be form created in view and not in controller? 2010-07-14

    Zend_Form:: When should be form created in view and not in controller? option 1 - form created in controller and passed to view (usually used) controller: $form=new MyForm(); $this->view->form=$form; view: echo $this->form; option 2 - form c

Copyright (C), All Rights Reserved.

processed in 0.530 (s). 13 q(s)