Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions config/translation-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@
'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,
'cache' => !env('APP_DEBUG', false),

/**
* Collect new keys
*/
'collect' => env('APP_DEBUG', false),

/**
* Use locales from files as a fallback option. Be aware that
Expand Down
4 changes: 2 additions & 2 deletions src/DatabaseLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public function addNamespace($namespace, $hint) {}
*/
public function addTranslation($locale, $group, $key)
{
if(!\Config::get('app.debug') || \Config::get('translation-db.minimal')) return;
if(!\Config::get('translation-db.collect')) return;

// Extract the real key from the translation.
if (preg_match("/^{$group}\.(.*?)$/sm", $key, $match)) {
if (preg_match("/^{$group}\\.(.*?)$/sm", $key, $match)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've seem to have added an extra slash. This slash however will break functionality. The single slash is intended to restrain the following dot from being counted as a wildcard character. Adding an extra slash would result in the dot being a wildcard.

$name = $match[1];
} else {
throw new TranslationException('Could not extract key from translation.');
Expand Down
2 changes: 1 addition & 1 deletion src/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,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') || \Config::get('translation-db.minimal')) {
if(\Config::get('translation-db.cache')) {
$that = $this;
$lines = \Cache::rememberForever('__translations.'.$locale.'.'.$group, function() use ($that, $locale, $group, $namespace) {
return $that->loadFromDatabase($namespace, $group, $locale);
Expand Down