Skip to content

Commit bf96a97

Browse files
committed
git push origin masterMerge branch 'ahmedash95-master'
2 parents 68fa9a3 + 3a2086f commit bf96a97

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

src/LangmanServiceProvider.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ public function register()
2323

2424
$this->app->bind(Manager::class, function () {
2525
return new Manager(
26-
new Filesystem(),
26+
new Filesystem,
2727
$this->app['config']['langman.path'],
28-
$this->app['config']['view.paths']
28+
array_merge($this->app['config']['view.paths'], [$this->app['path']])
2929
);
3030
});
3131

3232
$this->commands([
33-
\Themsaid\Langman\Commands\ShowCommand::class,
34-
\Themsaid\Langman\Commands\FindCommand::class,
35-
\Themsaid\Langman\Commands\TransCommand::class,
3633
\Themsaid\Langman\Commands\MissingCommand::class,
3734
\Themsaid\Langman\Commands\RemoveCommand::class,
35+
\Themsaid\Langman\Commands\TransCommand::class,
36+
\Themsaid\Langman\Commands\ShowCommand::class,
37+
\Themsaid\Langman\Commands\FindCommand::class,
3838
\Themsaid\Langman\Commands\SyncCommand::class,
3939
]);
4040
}

src/Manager.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ class Manager
2525
private $path;
2626

2727
/**
28-
* the paths to the views files.
28+
* The paths to directories where we look for localised strings to sync.
2929
*
3030
* @var array
3131
*/
32-
private $viewsPaths;
32+
private $syncPaths;
3333

3434
/**
3535
* Manager constructor.
3636
*
3737
* @param Filesystem $disk
3838
* @param string $path
3939
*/
40-
public function __construct(Filesystem $disk, $path, array $viewsPaths)
40+
public function __construct(Filesystem $disk, $path, array $syncPaths)
4141
{
4242
$this->disk = $disk;
4343
$this->path = $path;
44-
$this->viewsPaths = $viewsPaths;
44+
$this->syncPaths = $syncPaths;
4545
}
4646

4747
/**
@@ -261,7 +261,8 @@ public function collectFromViews()
261261
$functions = ['trans', 'trans_choice', 'Lang::get', 'Lang::choice', 'Lang::trans', 'Lang::transChoice', '@lang', '@choice'];
262262

263263
$pattern =
264-
// See http://regexr.com/392hu
264+
// See https://regex101.com/r/jS5fX0/1
265+
'[^\w]'. // Must not start with any alpha numeric character or underscore
265266
'('.implode('|', $functions).')'.// Must start with one of the functions
266267
"\(".// Match opening parentheses
267268
"[\'\"]".// Match " or '
@@ -274,7 +275,7 @@ public function collectFromViews()
274275
;
275276

276277
/** @var \Symfony\Component\Finder\SplFileInfo $file */
277-
foreach ($this->disk->allFiles($this->viewsPaths) as $file) {
278+
foreach ($this->disk->allFiles($this->syncPaths) as $file) {
278279
if (preg_match_all("/$pattern/siU", $file->getContents(), $matches)) {
279280
foreach ($matches[2] as $key) {
280281
try {

tests/SyncCommandTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,11 @@ public function testCommandOutputForFile()
3434
array_map('unlink', glob(__DIR__.'/views_temp/user/index.blade.php'));
3535
array_map('rmdir', glob(__DIR__.'/views_temp/user'));
3636
array_map('unlink', glob(__DIR__.'/views_temp/user.blade.php'));
37+
38+
array_map('unlink', glob(__DIR__.'/app_temp/Http/Controllers/testController.php'));
39+
array_map('unlink', glob(__DIR__.'/app_temp/Jobs/testJob.php'));
40+
array_map('rmdir', glob(__DIR__.'/app_temp/Http/Controllers'));
41+
array_map('rmdir', glob(__DIR__.'/app_temp/Http'));
42+
array_map('rmdir', glob(__DIR__.'/app_temp/Jobs'));
3743
}
3844
}

0 commit comments

Comments
 (0)