Skip to content

Commit

Permalink
Merge pull request #44 from lsmith77/custom_regexp
Browse files Browse the repository at this point in the history
Custom regexp
  • Loading branch information
kg-bot authored Oct 14, 2019
2 parents fd678f7 + f8e02cf commit f3b7126
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/Classes/ExportLocalizations.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ class ExportLocalizations implements \JsonSerializable
/**
* @var string
*/
protected $phpRegex = '/^.+\.php$/i';
protected $phpRegex;

/**
* @var string
*/
protected $jsonRegex = '/^.+\.json$/i';
protected $jsonRegex;

/**
* @var string
Expand All @@ -38,6 +38,18 @@ class ExportLocalizations implements \JsonSerializable
*/
protected $packageSeparator = '.';

/**
* ExportLocalizations constructor.
*
* @param string $phpRegex
* @param string $jsonRegex
*/
public function __construct($phpRegex, $jsonRegex)
{
$this->phpRegex = $phpRegex;
$this->jsonRegex = $jsonRegex;
}

/**
* Method to return generate array with contents of parsed language files.
*
Expand Down
5 changes: 4 additions & 1 deletion src/LaravelLocalizationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ class LaravelLocalizationServiceProvider extends ServiceProvider
public function boot()
{
$this->app->bind('export-localization', function () {
return new ExportLocalizations();
$phpRegex = config('laravel-localization.file_regexp.php');
$jsonRegex = config('laravel-localization.file_regexp.json');

return new ExportLocalizations($phpRegex, $jsonRegex);
});

/*
Expand Down
7 changes: 7 additions & 0 deletions src/config/laravel-localization.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,12 @@
*/
'lang_dirs' => [resource_path('lang')],
],
/*
* You can customize the regexp for lang files to be able to exclude certain files.
*/
'file_regexp' => [
'php' => '/^.+\.php$/i',
'json' => '/^.+\.json$/i',
],

];

0 comments on commit f3b7126

Please sign in to comment.