-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating a loading backend translation hook
- Loading branch information
Showing
2 changed files
with
40 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Modules\Core\Events; | ||
|
||
/** | ||
* Hook LoadingBackendTranslations | ||
* Triggered when loading the backend | ||
* Used to send laravel translations to the frontend | ||
* Example for VueJS | ||
* @package Modules\Core\Events | ||
*/ | ||
class LoadingBackendTranslations | ||
{ | ||
private $translations = []; | ||
|
||
public function getTranslations() : array | ||
{ | ||
return $this->translations; | ||
} | ||
|
||
public function load($key, array $translations) | ||
{ | ||
$this->translations = array_merge($this->translations, [$key => $translations]); | ||
|
||
return $this; | ||
} | ||
|
||
public function loadMultiple(array $translations) | ||
{ | ||
$this->translations = array_merge($this->translations, $translations); | ||
|
||
return $this; | ||
} | ||
} |