strings = array(); $this->LoadInternal("english"); $this->LoadInternal($locale); } public function LoadInternal($locale) { global $cphp_config; if(!isset($cphp_config->locale->path) || !isset($cphp_config->locale->extension)) { throw new Exception("The locale path settings are not specified correctly. Refer to the CPHP manual for instructions."); } $lng_contents = file_get_contents("{$cphp_config->locale->path}/{$locale}.{$cphp_config->locale->extension}"); if($lng_contents !== false) { $lines = explode("\n", $lng_contents); foreach($lines as $line) { $line = str_replace("\r", "", $line); if(preg_match("/(.+?[^\\\]);(.+)/", $line, $matches)) { $key = trim(str_replace("\;", ";", $matches[1])); $value = trim(str_replace("\;", ";", $matches[2])); switch($key) { case "_locale": $this->locale = explode(",", $value); break; case "_datetime_short": $this->datetime_short = $value; break; case "_datetime_long": $this->datetime_long = $value; break; case "_date_short": $this->date_short = $value; break; case "_date_long": $this->date_long = $value; break; case "_time": $this->time = $value; break; default: $this->strings[$key] = $value; break; } } } $this->name = $locale; } else { Throw new Exception("Failed to load locale {$locale}."); } } }