EllisLab text mark
Advanced Search
     
Loader class add_package_path and language support
Posted: 29 November 2011 07:58 PM
Joined: 2010-02-18
4 posts

Hey guys

I’m trying to set up some package libraries here, and I want to have custom language files associated with the library data.

I read on this page -> http://ellislab.com/codeigniter/user-guide/libraries/loader.html that you can add a language folder containing your various files, like so:

/application/third_party/foo_bar

config/
helpers/
language/
libraries/
models/

It’s not loading the language automatically, so I tried doing a lang->load(‘common’) (my language file is common_lang.php) right after calling add_package_path but still no luck.

I looked in the loader class and I don’t see anything that deals with language support.

Is this an oversight? Should I add it in myself? Or am I doing it wrong?

Loader.php:

public function add_package_path($path$view_cascade=TRUE)
 
{
  $path 
rtrim($path'/').'/';

  
array_unshift($this->_ci_library_paths$path);
  
array_unshift($this->_ci_model_paths$path);
  
array_unshift($this->_ci_helper_paths$path);

  
$this->_ci_view_paths = array($path.'views/' => $view_cascade) + $this->_ci_view_paths;

  
// Add config file path
  
$config =& $this->_ci_get_component('config');
  
array_unshift($config->_config_paths$path);
 

Thanks for the help

 
Posted: 29 November 2011 08:21 PM   [ # 1 ]   [ Rating: 0 ]
Joined: 2010-02-18
4 posts

Edit:

I realized you have to load a custom language file along with loading your library, but the language file can’t be the same name as the file you’ve already loaded.

So, I can’t have

application/language/english/common_lang.php

and

application/packages/whatever/language/english/common_lang.php

The loader think that file is already loaded.

It would be nice if the package loader could simply check to see if there is a language file already loaded, but I guess that’s asking too much smile

 
Posted: 29 November 2011 08:46 PM   [ # 2 ]   [ Rating: 0 ]
Joined: 2010-02-18
4 posts

Actually it’s simple enough just to put it in the class constructor

Don’t mind me, I’m just an idiot