Skip to content

Commit

Permalink
Allow disabling the collection functionality and retrieve keys from c…
Browse files Browse the repository at this point in the history
…ache. Setting: minimal.
  • Loading branch information
hpolthof committed Jun 16, 2015
1 parent 43915b9 commit 00310b6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions config/translation-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
2 changes: 1 addition & 1 deletion src/DatabaseLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 00310b6

Please sign in to comment.