Login   Register  
PHP Classes
elePHPant
Icontem

File: class/olocale.cls.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Johan Barbier  >  Class Doc  >  class/olocale.cls.php  >  Download  
File: class/olocale.cls.php
Role: Class source
Content type: text/plain
Description: localization class
Class: Class Doc
Generate PHP code documentation in multiple idioms
Author: By
Last change: Changed localization : in the 'locales' folder, one sub-folder for each supported language. And in each of these sub folders, one xml file for each messages type (documentation, errors and ui).
Date: 8 years ago
Size: 779 bytes
 

Contents

Class file image Download
<?php
class olocale {

    private 
$aMessages = array ();

    private 
$locale '';

    public function 
__construct ($loc) {
        
$this -> locale $loc;
        
$this -> setaMessages ();
    }

    private function  
setaMessages () {
        
$aFiles scandir ('locales/'.$this -> locale);
        
$aForbid = array ('.''..');
        
$aFiles array_diff ($aFiles$aForbid);
        foreach (
$aFiles as $file) {
            
$cat substr ($file0strlen ($file) -4);
            
$xml simplexml_load_file('locales/'.$this -> locale.'/'.$file);
            foreach (
$xml  as $clef => $val) {
                
$this -> aMessages[$cat][$clef] = $val;
            }
        }
    }

    public function 
getMsg ($cat$clef) {
        return (string)
$this -> aMessages[$cat][$clef];
    }

    public function 
getLoc () {
        return (string)
$this -> locale;
    }
}
?>