i18n::load PHP Method

load() protected method

protected load ( $filename )
    protected function load($filename)
    {
        $ext = substr(strrchr($filename, '.'), 1);
        switch ($ext) {
            case 'properties':
            case 'ini':
                $config = parse_ini_file($this->langFilePath, true);
                break;
            case 'yml':
                if (!class_exists('Spyc')) {
                    require_once 'vendor/spyc.php';
                }
                $config = spyc_load_file($this->langFilePath);
                break;
            case 'json':
                $config = json_decode(file_get_contents($this->langFilePath), true);
                break;
            default:
                throw new InvalidArgumentException($ext . " is not a valid extension!");
        }
        return $config;
    }

Usage Example

Example #1
0
File: i18n.php Project: ukd1/kohana
 /**
  * Returns translation of a string. If no translation exists, the original
  * string will be returned.
  *
  * @param   string   text to translate
  * @return  string
  */
 public static function get($string)
 {
     // Load the translation table
     $table = i18n::load(i18n::$lang);
     // Return the translated string if it exists
     return isset($table[$string]) ? $table[$string] : $string;
 }
All Usage Examples Of i18n::load