PHP Classes

File: class/olocale.cls.php

Recommend this page to a friend!
  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: 18 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 ($file, 0, strlen ($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;
    }
}
?>