From 2e5e229474cf02f64a796034b3a0e194099e1538 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Fri, 30 Sep 2016 19:03:30 -0400 Subject: [PATCH] Fixes to Lang class --- locale/en.php | 2 +- vendor/JKingWeb/NewsSync/Lang.php | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/locale/en.php b/locale/en.php index 7b99d963..1a7e7dc7 100644 --- a/locale/en.php +++ b/locale/en.php @@ -1,5 +1,5 @@ "Default language file \"{0}\" missing", "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}\"", diff --git a/vendor/JKingWeb/NewsSync/Lang.php b/vendor/JKingWeb/NewsSync/Lang.php index 1065bce4..390b438c 100644 --- a/vendor/JKingWeb/NewsSync/Lang.php +++ b/vendor/JKingWeb/NewsSync/Lang.php @@ -6,13 +6,16 @@ class Lang { const PATH = BASE."locale".DIRECTORY_SEPARATOR; const DEFAULT = "en"; const REQUIRED = [ - "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.defaultFileMissing" => "Default language file \"{0}\" missing", + "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 $synched = false; - static protected $wanted = "fr"; + static protected $wanted = self::DEFAULT; static protected $locale = ""; static protected $loaded = []; static protected $strings = self::REQUIRED; @@ -115,7 +118,7 @@ class Lang { foreach($files as $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(!@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 self::$strings = call_user_func_array("array_replace_recursive", $strings);