In Codeigniter 2, how do I load a library into a global variable I can use in helper functions?
<p>So I have the following files:</p>

<p>libraries/foo_library.php</p>

<p>helpers/foo_helper.php</p>

<p>views/main.php</p>

<p>Now my problem:
The library I've created is going to be used hundreds of times on each page load since it's used for determining the language and returning the correct item depending on the language stored in the database.</p>

<pre><code>&lt;?=$this-&gt;foo_library-&gt;language('English');?&gt;
</code></pre>

<p>Now when used that way it works fine, though since I'm going to be using it for other language operations in the views, I created a few helper functions to make the views look cleaner</p>

<pre><code>&lt;?=sl('English words','Other language words')?&gt;
</code></pre>

<p>Now this does work to an extent, though the <strong>helper ends up creating a new object from the library every time the function is run</strong> (Basically using the $CI =&amp; get_instance() method to call the library).</p>

<p>This is a problem, since when you create the library, it saves data into memory so it doesn't need to keep querying the database. So <strong>when the object gets recreated over and over again, it completely defeats the purpose</strong>.</p>

<p>So I wanted to know, is there any clean way for my to create a library object that can be used anywhere in the project, including helper functions, and maintain it's persistence? (<strong>The library does use the db builder class from CI</strong>)</p>