-
Notifications
You must be signed in to change notification settings - Fork 0
Lang Uri
[b]Lang_uri Library[/b] Supplementary code for URI Language Identifier.
[b]Installation[/b] copy Lang_uri.php to application/libraries Autoload or load whenever needed.
[b]Configuration[/b] (config.php) [code] //from ci configuration $config['language'] = "greek";
//added for multilanguage
//for URI Language Identifier ------------- //default language abbreviation $config['language_abbr'] = "el"; //set available language abbreviations $config['lang_uri_abbr'] = array("el" => "greek", "en" => "english"); //ignore this language abbreviation $config['lang_ignore'] = TRUE; // redirect on invalid language abbreviation $config['lang_redirect_url'] = $config['base_url'].$config['index_page']."el/error_404";
//for Lang_uri ------------- $config['lang_ignore_abbr'] = "el"; //language descriptions $config['lang_desc'] = array("el"=>"Ελληνικά","en" => "English"); //language use images $config['lang_useimg'] = TRUE; //or false to use only text //language use images $config['lang_img_path'] = 'img/'; //
//end of multilanguage [/code]
[b]Parameters[/b] [quote] [b]uri[/b] Leave blank for current url
[b]slug[/b] pass array in the format ('lang_abbr'=>'slug-to-add')
[b]stripsegment[/b] if needed to delete last segment (when using slug)
[b]exclude_current[/b] don't return anything for current language
[b]nolink_current[/b] don't return link for current language but display
[b]link_open_tag[/b] open tag for link
[b]link_close_tag[/b] close tag for link
[b]nolink_open_tag[/b] open tag for no link
[b]nolink_close_tag[/b] close tag for no link
[b]divider[/b] divider, ie '
', leave empty for no use[b]link_extra_global[/b] accepts a string for global link class, ie 'class="lang_links"'
[b]link_extra_lang[/b] array for specific lang details ('lang_abbr'=>'class="some" id="en_lang"'), leave empty for no use
[b]lang_useimg[/b] Values TRUE/FALSE.if not set it reads setting from config file
[b]lang_img_path[/b] path for flag imgs. needs trailing slash. path is absolute (using base_url()). empty for value from config
[b]lang_img_ext[/b] file extension for flag imgs. imgs must have the lang_ as filename, ie en.png, el.png, etc [/quote]
[b]Usage[/b] Load your library [code] $this->load->library('lang_uri'); [/code]
To Simply display all language urls of current url use [code] $this->lang_uri->create_links(); [/code]
To add configuration to exclude current Parameters (passed during loading or through initialize function if you are autoloading the library). [code] $config['exclude_current'] = TRUE; $this->lang_uri->initialize($config); $this->lang_uri->create_links(); [/code]
to make the links be ie list items (common use for menus) and assign a class or style in the links [code] $config['link_open_tag'] = '
To use slugs for languages, ie news/article/post-title-in-english, news/article/post-title-in-greek Note: if your current url is news/article/post-title-in-english you'll need to set stripsegment to true too.
[code] $config['stripsegment'] = TRUE; $config['slug'] = array('el' => 'post-title-in-greek', 'en' => 'post-title-in-english'); $this->lang_uri->initialize($config); $this->lang_uri->create_links(); [/code]