Welcome Guest, Not a member yet? Register   Sign In
Placeholders in language lines
#2

(This post was last modified: 06-10-2018, 05:01 AM by InsiteFX.)

Maybe this will help, you can use it in any library Class.


PHP Code:
// Your lang file - Created under language folder language-name
<<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

$lang['your key'] = "Your Message.";

// End of lang file


// Your Class
class Your_Class
{
 
   /**
     * @var  CI_Controller - The CI Super Object
     */
 
   protected $CI;

 
   /**
     * constructor.
     * -------------------------------------------------------------------
     *
     */
 
   public function __construct()
 
   {
 
       $this->CI =& get_instance();

 
       $this->CI->lang->load('your lang file''english');
 
   }

 
   /**
     * Your Method.
     * -------------------------------------------------------------------
     *
     */
 
   public function test()
 
   {
 
       show_error($this->CI->lang->line('your message'));
 
       
        
// or

 
       echo $this->CI->lang->line('your message');
 
   }


 
When working outside of a controller you need to get the CodeIgniter Super Object.

Also SEE: The CodeIgniter Documentation on Language files etc;
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
Placeholders in language lines - by glorsh66 - 06-10-2018, 12:00 AM
RE: Placeholders in language lines - by InsiteFX - 06-10-2018, 04:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB