diff --git a/config/translation-db.php b/config/translation-db.php index f0b049b..7da2ad5 100644 --- a/config/translation-db.php +++ b/config/translation-db.php @@ -26,4 +26,12 @@ * You can however turn it on, the choice is yours. */ 'disable_debugbar' => true, + + /** + * - Force translations to be cached, even in Debug Mode. + * - And disables the collection of new keys. + * This can be used to prevent lots of queries from + * happening. + */ + 'minimal' => false, ]; diff --git a/src/DatabaseLoader.php b/src/DatabaseLoader.php index e0a52ca..1c6735f 100644 --- a/src/DatabaseLoader.php +++ b/src/DatabaseLoader.php @@ -52,7 +52,7 @@ public function addNamespace($namespace, $hint) {} */ public function addTranslation($locale, $group, $key) { - if(!\Config::get('app.debug')) return; + if(!\Config::get('app.debug') || \Config::get('translation-db.minimal')) return; // Extract the real key from the translation. if (preg_match("/^{$group}\.(.*?)$/sm", $key, $match)) { diff --git a/src/Translator.php b/src/Translator.php index 446823e..ef6840b 100644 --- a/src/Translator.php +++ b/src/Translator.php @@ -68,7 +68,7 @@ public function load($namespace, $group, $locale) // This will allow legacy support. if(!self::isNamespaced($namespace)) { // If debug is off then cache the result forever to ensure high performance. - if(!\Config::get('app.debug')) { + if(!\Config::get('app.debug') || \Config::get('translation-db.minimal')) { $that = $this; $lines = \Cache::rememberForever('__translations.'.$locale.'.'.$group, function() use ($that, $locale, $group, $namespace) { return $this->database->load($locale, $group, $namespace);