How to include language file in php classes

Discussion in 'PHP' started by dmm2020, Jul 3, 2010.

  1. #1
    What is the best way to include php language file (i.e., ./language/english/license.php) in a class file (i.e., class.license.php) whereas I can use the variables in the language license.php in the class object?

    Trying to learn differences between OOP and procedural language and this one is confusing me.
     
    dmm2020, Jul 3, 2010 IP
  2. Rainulf

    Rainulf Active Member

    Messages:
    373
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #2
    You need to elaborate. You can add the following php statement to include language file in your class file:
    include './language/english/license.php';
    Code (markup):
    And you should be able to use variables, functions, etc from the language file.
     
    Rainulf, Jul 3, 2010 IP
  3. RobiMac

    RobiMac Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If you mean localization, you can use the ISO code to construct the path to the appropriate file, here is a bit of example code, but it is untested and may or may not suit your needs:

    
    function get_localized_license($iso) {
        require_once("/language/{$iso}/license.php");
    }
    
    PHP:
    Good luck!
     
    RobiMac, Jul 4, 2010 IP