Skip to content

Commit c01ccf5

Browse files
Merge pull request #256 from laravel/huge-translations
Translation performance improvements
2 parents 1dcae08 + a948b37 commit c01ccf5

File tree

12 files changed

+606
-371
lines changed

12 files changed

+606
-371
lines changed

php-templates/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
return [
1515
$key => [
16-
'path' => vsCodeToRelativePath($closureClass->getFileName()),
16+
'path' => LaravelVsCode::relativePath($closureClass->getFileName()),
1717
'class' => $closureClass->getName(),
1818
'line' => $boundTo->getStartLine(),
1919
],

php-templates/bootstrap-laravel.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@
77
require_once __DIR__ . '/../autoload.php';
88
$app = require_once __DIR__ . '/../../bootstrap/app.php';
99

10-
class VsCodeLaravel extends \Illuminate\Support\ServiceProvider
10+
$app->register(new class($app) extends \Illuminate\Support\ServiceProvider
1111
{
12-
public function register()
13-
{
14-
}
15-
1612
public function boot()
1713
{
1814
config([
@@ -23,18 +19,20 @@ public function boot()
2319
'logging.default' => 'null',
2420
]);
2521
}
26-
}
22+
});
2723

28-
function vsCodeToRelativePath($path)
24+
class LaravelVsCode
2925
{
30-
if (!str_contains($path, base_path())) {
31-
return (string) $path;
32-
}
26+
public static function relativePath($path)
27+
{
28+
if (!str_contains($path, base_path())) {
29+
return (string) $path;
30+
}
3331

34-
return ltrim(str_replace(base_path(), '', realpath($path)), DIRECTORY_SEPARATOR);
32+
return ltrim(str_replace(base_path(), '', realpath($path)), DIRECTORY_SEPARATOR);
33+
}
3534
}
3635

37-
$app->register(new VsCodeLaravel($app));
3836
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
3937
$kernel->bootstrap();
4038

php-templates/inertia.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
$config = config('inertia.testing', []);
44

55
$pagePaths = collect($config['page_paths'] ?? [])->map(function($path) {
6-
return vsCodeToRelativePath($path);
6+
return LaravelVsCode::relativePath($path);
77
});
88

99
$config['page_paths'] = $pagePaths->toArray();

php-templates/middleware.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
return [
2828
"class" => $m,
29-
"path" => vsCodeToRelativePath($reflected->getFileName()),
29+
"path" => LaravelVsCode::relativePath($reflected->getFileName()),
3030
"line" =>
3131
$reflectedMethod->getFileName() === $reflected->getFileName()
3232
? $reflectedMethod->getStartLine()
@@ -42,7 +42,7 @@
4242

4343
$result = array_merge($result, [
4444
"class" => $middleware,
45-
"path" => vsCodeToRelativePath($reflected->getFileName()),
45+
"path" => LaravelVsCode::relativePath($reflected->getFileName()),
4646
"line" => $reflectedMethod->getStartLine(),
4747
]);
4848

0 commit comments

Comments
 (0)