如何使codeigniter网站多语言阿拉伯语和法语[重复]

This question already has an answer here:

I've been researching for hours and hours, but I could not find a clear, efficient way to solve my problem.

I have 2 templates(header+content+footer) in Arabic & french. For each language different pages and different functions are in my controller. How can I make a multilingual website?

To pass in my link ?lang=fr or ?lang=ar without compromising my link which is similar to: localhost/site/controleur/method/id

Ps: i'm using a mysql db .

</div>

Yes you can create a separate lang folder(for each language) having a file with similar keys but the value(text) will be according to language type. And then include that particular language file(folder) on request by identifier.

Why don't you just use sub-folders for your controllers based on the language?

controllers/ar/my_controller.php
controllers/fr/my_controller.php

http://www.example.com/fr/home
http://www.example.com/ar/home

Why do you need different pages for your website? IMO, you need to switch templates or load different controllers based on the language

Just in case and if you are just starting your project, you may find Bonfire much better suited for this. It supports templating and internationalization in a much easier way.

Codeigniter has already provided with multi language facility, Its internationalization support,

All you need is a controller, language files, and view.

Based on the selected language, your controller will load the respective language file, and the view file will display the templates written in the language file.

Your language file will look something like this

$lang['language_key'] = "The actual message to be shown";

Your controller, the value of the siteLang can be retrieved either from the url, or you can have it stored as cookie in the browser.

function home(){ 
    $this->lang->load('home', $this->siteLang);   
}

Your view will look like, through this the value of the language_key will be displayed on that controller.

<?php echo $this->lang->line('language_key'); ?>

Some key points like the nomencalature of the lang files etc, You can find more about it, at the below link http://ellislab.com/codeigniter/user-guide/libraries/language.html