Skip to content

Commit

Permalink
Refactor, refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
hadefication committed Aug 16, 2017
1 parent f8c775e commit 8970b2f
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/Polyglot.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,33 @@ public function __construct(Translator $translator)
}

/**
* Generate tranlation keys and export the trans function
* Compile translation files to array
*
* @return String
* @return Array
*/
public function generate()
public function compileTranslationFiles()
{
$translations = [];

// Get translation files
$files = config('polyglot.files');

$translations = [];

foreach ($files as $key => $file) {
// Load all translation keys filed under the translation file
$translations[$file] = $this->translator->trans($file);
}

$json = json_encode($translations);
return $translations;
}

/**
* Generate tranlation keys and export the trans function
*
* @return String
*/
public function generate()
{
$json = json_encode($this->compileTranslationFiles());
$transFunction = file_get_contents(__DIR__ . '/dist/js/trans.min.js');

return <<<EOT
Expand Down

0 comments on commit 8970b2f

Please sign in to comment.