1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 13:12:41 +00:00

Fixes to Lang class

This commit is contained in:
J. King 2016-09-30 19:03:30 -04:00
parent db0bd18663
commit 2e5e229474
2 changed files with 8 additions and 5 deletions

View file

@ -1,5 +1,5 @@
<?php <?php
$string[] = [ return [
"Exception.JKingWeb/NewsSync/Lang/Exception.defaultFileMissing" => "Default language file \"{0}\" missing", "Exception.JKingWeb/NewsSync/Lang/Exception.defaultFileMissing" => "Default language file \"{0}\" missing",
"Exception.JKingWeb/NewsSync/Lang/Exception.fileMissing" => "Language file \"{0}\" is not available", "Exception.JKingWeb/NewsSync/Lang/Exception.fileMissing" => "Language file \"{0}\" is not available",
"Exception.JKingWeb/NewsSync/Lang/Exception.fileUnreadable" => "Insufficient permissions to read language file \"{0}\"", "Exception.JKingWeb/NewsSync/Lang/Exception.fileUnreadable" => "Insufficient permissions to read language file \"{0}\"",

View file

@ -6,13 +6,16 @@ class Lang {
const PATH = BASE."locale".DIRECTORY_SEPARATOR; const PATH = BASE."locale".DIRECTORY_SEPARATOR;
const DEFAULT = "en"; const DEFAULT = "en";
const REQUIRED = [ const REQUIRED = [
"Exception.JKingWeb/NewsSync/Lang/Exception.defaultFileMissing" => "Default language file ({0}) missing", "Exception.JKingWeb/NewsSync/Lang/Exception.defaultFileMissing" => "Default language file \"{0}\" missing",
"Exception.JKingWeb/NewsSync/Lang/Exception.stringMissing" => "Message string \"{msgID}\" missing from all loaded language files ({fileList})" "Exception.JKingWeb/NewsSync/Lang/Exception.fileMissing" => "Language file \"{0}\" is not available",
"Exception.JKingWeb/NewsSync/Lang/Exception.fileUnreadable" => "Insufficient permissions to read language file \"{0}\"",
"Exception.JKingWeb/NewsSync/Lang/Exception.fileCorrupt" => "Language file \"{0}\" is corrupt or does not conform to expected format",
"Exception.JKingWeb/NewsSync/Lang/Exception.stringMissing" => "Message string \"{msgID}\" missing from all loaded language files ({fileList})",
]; ];
static protected $requirementsMet = false; static protected $requirementsMet = false;
static protected $synched = false; static protected $synched = false;
static protected $wanted = "fr"; static protected $wanted = self::DEFAULT;
static protected $locale = ""; static protected $locale = "";
static protected $loaded = []; static protected $loaded = [];
static protected $strings = self::REQUIRED; static protected $strings = self::REQUIRED;
@ -115,7 +118,7 @@ class Lang {
foreach($files as $file) { foreach($files as $file) {
if(!file_exists(self::PATH."$file.php")) throw new Lang\Exception("fileMissing", $file); if(!file_exists(self::PATH."$file.php")) throw new Lang\Exception("fileMissing", $file);
if(!is_readable(self::PATH."$file.php")) throw new Lang\Exception("fileUnreadable", $file); if(!is_readable(self::PATH."$file.php")) throw new Lang\Exception("fileUnreadable", $file);
if(!@include(self::PATH."$file.php")) throw new Lang\Exception("fileCorrupt", $file); if(!$strings[] = (@include self::PATH."$file.php")) throw new Lang\Exception("fileCorrupt", $file);
} }
// apply the results and return // apply the results and return
self::$strings = call_user_func_array("array_replace_recursive", $strings); self::$strings = call_user_func_array("array_replace_recursive", $strings);