-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 14b74eb
Showing
10 changed files
with
480 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | ||
/* | ||
| ------------------------------------------------------------------- | ||
| AUTO-LOADER | ||
| ------------------------------------------------------------------- | ||
| This file specifies which systems should be loaded by default. | ||
| | ||
| In order to keep the framework as light-weight as possible only the | ||
| absolute minimal resources are loaded by default. For example, | ||
| the database is not connected to automatically since no assumption | ||
| is made regarding whether you intend to use it. This file lets | ||
| you globally define which systems you would like loaded with every | ||
| request. | ||
| | ||
| ------------------------------------------------------------------- | ||
| Instructions | ||
| ------------------------------------------------------------------- | ||
| | ||
| These are the things you can load automatically: | ||
| | ||
| 1. Packages | ||
| 2. Libraries | ||
| 3. Helper files | ||
| 4. Custom config files | ||
| 5. Language files | ||
| 6. Models | ||
| | ||
*/ | ||
|
||
/* | ||
| ------------------------------------------------------------------- | ||
| Auto-load Packges | ||
| ------------------------------------------------------------------- | ||
| Prototype: | ||
| | ||
| $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared'); | ||
| | ||
*/ | ||
|
||
$autoload['packages'] = array(); | ||
|
||
|
||
/* | ||
| ------------------------------------------------------------------- | ||
| Auto-load Libraries | ||
| ------------------------------------------------------------------- | ||
| These are the classes located in the system/libraries folder | ||
| or in your application/libraries folder. | ||
| | ||
| Prototype: | ||
| | ||
| $autoload['libraries'] = array('database', 'session', 'xmlrpc'); | ||
*/ | ||
|
||
$autoload['libraries'] = array(); | ||
|
||
|
||
/* | ||
| ------------------------------------------------------------------- | ||
| Auto-load Helper Files | ||
| ------------------------------------------------------------------- | ||
| Prototype: | ||
| | ||
| $autoload['helper'] = array('url', 'file'); | ||
*/ | ||
|
||
$autoload['helper'] = array('url', 'language', 'mci'); | ||
|
||
|
||
/* | ||
| ------------------------------------------------------------------- | ||
| Auto-load Config files | ||
| ------------------------------------------------------------------- | ||
| Prototype: | ||
| | ||
| $autoload['config'] = array('config1', 'config2'); | ||
| | ||
| NOTE: This item is intended for use ONLY if you have created custom | ||
| config files. Otherwise, leave it blank. | ||
| | ||
*/ | ||
|
||
$autoload['config'] = array(); | ||
|
||
|
||
/* | ||
| ------------------------------------------------------------------- | ||
| Auto-load Language files | ||
| ------------------------------------------------------------------- | ||
| Prototype: | ||
| | ||
| $autoload['language'] = array('lang1', 'lang2'); | ||
| | ||
| NOTE: Do not include the "_lang" part of your file. For example | ||
| "codeigniter_lang.php" would be referenced as array('codeigniter'); | ||
| | ||
*/ | ||
|
||
$autoload['language'] = array('mci'); | ||
|
||
|
||
/* | ||
| ------------------------------------------------------------------- | ||
| Auto-load Models | ||
| ------------------------------------------------------------------- | ||
| Prototype: | ||
| | ||
| $autoload['model'] = array('model1', 'model2'); | ||
| | ||
*/ | ||
|
||
$autoload['model'] = array(); | ||
|
||
|
||
/* End of file autoload.php */ | ||
/* Location: ./application/config/autoload.php */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | ||
|
||
/** | ||
* Config for Multilingual CI | ||
* | ||
* Default language is set in the config.php - $config['language'] = 'english'; | ||
* | ||
* by Tanel Tammik - keevitaja@gmail.com - 2012 | ||
* | ||
* version 1.0 | ||
* | ||
*/ | ||
|
||
// Supported languages | ||
// By adding/romoving languages changes must be done in routes.php as well | ||
$config['mci_languages']['en'] = 'english'; | ||
$config['mci_languages']['et'] = 'estonian'; | ||
$config['mci_languages']['ru'] = 'russian'; | ||
|
||
// Hides language segment for default language | ||
$config['mci_hide_default'] = TRUE; | ||
|
||
// html wrappers for language bar | ||
$config['mci_wrapper_language'] = "<span>%s</span>"; | ||
$config['mci_wrapper_section'] = "<nav>%s</nav>"; | ||
|
||
// display names for the language bar | ||
$config['mci_display']['en']['name'] = "ENG"; | ||
$config['mci_display']['en']['title'] = "In English"; | ||
$config['mci_display']['et']['name'] = "EST"; | ||
$config['mci_display']['et']['title'] = "Eesti Keeles"; | ||
$config['mci_display']['ru']['name'] = "RUS"; | ||
$config['mci_display']['ru']['title'] = "По-Русски"; | ||
|
||
/* End of file mci_languages.php */ | ||
/* Location: ./application/config/mci_languages.php */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | ||
/* | ||
| ------------------------------------------------------------------------- | ||
| URI ROUTING | ||
| ------------------------------------------------------------------------- | ||
| This file lets you re-map URI requests to specific controller functions. | ||
| | ||
| Typically there is a one-to-one relationship between a URL string | ||
| and its corresponding controller class/method. The segments in a | ||
| URL normally follow this pattern: | ||
| | ||
| example.com/class/method/id/ | ||
| | ||
| In some instances, however, you may want to remap this relationship | ||
| so that a different class/function is called than the one | ||
| corresponding to the URL. | ||
| | ||
| Please see the user guide for complete details: | ||
| | ||
| http://codeigniter.com/user_guide/general/routing.html | ||
| | ||
| ------------------------------------------------------------------------- | ||
| RESERVED ROUTES | ||
| ------------------------------------------------------------------------- | ||
| | ||
| There area two reserved routes: | ||
| | ||
| $route['default_controller'] = 'welcome'; | ||
| | ||
| This route indicates which controller class should be loaded if the | ||
| URI contains no data. In the above example, the "welcome" class | ||
| would be loaded. | ||
| | ||
| $route['404_override'] = 'errors/page_missing'; | ||
| | ||
| This route will tell the Router what URI segments to use if those provided | ||
| in the URL cannot be matched to a valid route. | ||
| | ||
*/ | ||
|
||
$route['default_controller'] = "example"; | ||
$route['404_override'] = ''; | ||
|
||
// All re-mappings must begin with '^(en|et|ru)' !!! | ||
|
||
$route['^(en|et|ru)/(.+)$'] = "$2"; | ||
$route['^(en|et|ru)$'] = $route['default_controller']; | ||
|
||
/* End of file routes.php */ | ||
/* Location: ./application/config/routes.php */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | ||
|
||
/** | ||
* Example controller for Multilingual CI | ||
* | ||
* requires language helper | ||
* | ||
* by Tanel Tammik - keevitaja@gmail.com - 2012 | ||
* | ||
* version 1.0 | ||
* | ||
*/ | ||
|
||
class Example extends CI_Controller { | ||
function index() { | ||
$data['i18n'] = $this->lang->mci_current(); | ||
$data['content'] = 'mci_example_1'; | ||
$data['uri'] = 'example/test'; | ||
|
||
$this->load->view('example', $data); | ||
} | ||
|
||
function test() { | ||
$data['i18n'] = $this->lang->mci_current(); | ||
$data['content'] = 'mci_example_2'; | ||
$data['uri'] = 'example'; | ||
|
||
$this->load->view('example', $data); | ||
} | ||
} | ||
|
||
/* End of file example.php */ | ||
/* Location: ./application/controllers/example.php */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | ||
|
||
/** | ||
* CORE Lang.php extension for Multilingual CI | ||
* | ||
* requires url helper | ||
* | ||
* by Tanel Tammik - keevitaja@gmail.com - 2012 | ||
* | ||
* version 1.0 | ||
* | ||
*/ | ||
|
||
class MY_Lang extends CI_Lang { | ||
private $mci_languages; | ||
private $mci_hide_default; | ||
private $mci_segment; | ||
private $mci_default_language; | ||
|
||
function __construct() { | ||
global $URI, $CFG; | ||
|
||
parent::__construct(); | ||
|
||
$CFG->load('mci_languages'); | ||
|
||
$this->mci_languages = $CFG->item('mci_languages'); | ||
$this->mci_hide_default = $CFG->item('mci_hide_default'); | ||
$this->mci_segment = $URI->segment(1, 0); | ||
$this->mci_default_language = array_search($CFG->item('language'), $this->mci_languages); | ||
|
||
if(array_key_exists($this->mci_segment, $this->mci_languages)) { | ||
$CFG->set_item('language', $this->mci_languages[$this->mci_segment]); | ||
} | ||
} | ||
|
||
// returns current language segment | ||
function mci_current() { | ||
return ((array_key_exists($this->mci_segment, $this->mci_languages)) ? $this->mci_segment : $this->mci_default_language); | ||
} | ||
|
||
// checks, if currently used language is default. returns bool | ||
function is_default() { | ||
return (($this->mci_current() == $this->mci_default_language) ? TRUE : FALSE); | ||
} | ||
|
||
// returns current uri without language segment | ||
function mci_clean_uri() { | ||
$ci =& get_instance(); | ||
|
||
$segments = $ci->uri->segment_array(); | ||
|
||
if(empty($segments)) { | ||
return; | ||
} | ||
|
||
if(array_key_exists($segments[1], $this->mci_languages)) { | ||
array_shift($segments); | ||
} | ||
|
||
return implode('/', $segments); | ||
} | ||
|
||
// returns uri string with language segment | ||
function mci_make_uri($language_segment, $uri = FALSE) { | ||
$uri = ($uri === FALSE) ? $this->mci_clean_uri() : trim($uri, '/'); | ||
|
||
if(!array_key_exists($language_segment, $this->mci_languages)) { | ||
return $uri; | ||
} | ||
|
||
if($language_segment == $this->mci_default_language AND $this->mci_hide_default === TRUE) { | ||
return $uri; | ||
} | ||
|
||
$uri = $language_segment.'/'.$uri; | ||
|
||
return $uri; | ||
} | ||
|
||
// returns html language bar | ||
function mci_language_bar() { | ||
$ci =& get_instance(); | ||
|
||
$display = $ci->config->item('mci_display'); | ||
|
||
$html = ''; | ||
|
||
foreach($this->mci_languages as $segment => $name) { | ||
$uri = $this->mci_make_uri($segment); | ||
|
||
$row = ($segment != $this->mci_current()) ? anchor($uri, $display[$segment]['name'], 'title="'.$display[$segment]['title'].'"') : $display[$segment]['name']; | ||
|
||
$html .= sprintf($ci->config->item('mci_wrapper_language'), $row); | ||
} | ||
|
||
return sprintf($ci->config->item('mci_wrapper_section'), $html); | ||
} | ||
} | ||
|
||
/* End of file MY_Lang.php */ | ||
/* Location: ./application/core/MY_lang.php */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | ||
|
||
/** | ||
* Helper functions for Multilingual CI | ||
* | ||
* requires url helper | ||
* | ||
* by Tanel Tammik - keevitaja@gmail.com - 2012 | ||
* | ||
* version 1.0 | ||
* | ||
*/ | ||
|
||
// Adds language segment to anchor uri | ||
// Use instead of anchor in multilingual projects | ||
function lanchor($uri = '', $title = '', $attributes = '') { | ||
$ci =& get_instance(); | ||
|
||
$uri = $ci->lang->mci_make_uri($ci->lang->mci_current(), $uri); | ||
|
||
return anchor($uri, $title, $attributes); | ||
} | ||
|
||
// Returns languge bar html | ||
// Html can be configured in mci_languages.php config file | ||
function langbar() { | ||
$ci =& get_instance(); | ||
|
||
return $ci->lang->mci_language_bar(); | ||
} | ||
|
||
/* End of file mci_helper.php */ | ||
/* Location: ./application/helpers/mci_helper.php */ |
Oops, something went wrong.