Skip to content

Commit

Permalink
add a exclude files config array
Browse files Browse the repository at this point in the history
  • Loading branch information
Findhel committed Mar 18, 2024
1 parent c6b3c62 commit 5316125
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions config/translation-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,12 @@
'remote_directory' => [
// 'my-package-name' => 'vendor/my-package-name/lang'
],

/**
* Translation files you want to exclude
*/
'exclude_files' => [
// 'my-filename.php',
// 'my-directory/my-filename.php',
],
];
5 changes: 4 additions & 1 deletion src/Console/SyncTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ class SyncTranslations extends Command
protected $availableRemoteDirectory = [];

protected $filesystem;
protected $excludeFiles = [];

public function __construct(Filesystem $filesystem)
{
parent::__construct();

$this->availableLocales = config('translation-loader.locales');
$this->availableRemoteDirectory = config('translation-loader.remote_directory');
$this->excludeFiles = config('translation-loader.exclude_files');
$this->filesystem = $filesystem;
$this->translationModel = config('translation-loader.model');
}
Expand All @@ -51,7 +53,8 @@ public function handle()

// Get all translations from base project
foreach ($this->filesystem->allFiles(lang_path()) as $file) {
if (! in_array($file->getExtension(), $this->availableFileExtensions)) {
if (! in_array($file->getExtension(), $this->availableFileExtensions)
|| in_array($file->getFilename(), $this->excludeFiles)) {
continue;
}
$relativePath = $file->getRelativePath();
Expand Down

0 comments on commit 5316125

Please sign in to comment.