Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- laravel: 11.*
testbench: ^9.9
- laravel: 10.*
testbench: 8.*
testbench: ^8.27.0
exclude:
- laravel: 12.*
php: 8.1
Expand Down
5 changes: 4 additions & 1 deletion src/TranslationLoaderServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ protected function registerLoader(): void
$this->app->singleton('translation.loader', function ($app) {
$aggregateLoader = config('translation-loader.aggregate_loader') ?? AggregateLoader::class;

return new $aggregateLoader($app['files'], $app['path.lang']);
return new $aggregateLoader($app['files'], [
base_path('vendor/laravel/framework/src/Illuminate/Translation/lang'),
$app['path.lang'],
]);
});
}

Expand Down
26 changes: 26 additions & 0 deletions tests/Feature/TranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException;
use Orchestra\Testbench\Attributes\UsesVendor;

final class TranslationTest extends TestCase
{
Expand Down Expand Up @@ -244,4 +245,29 @@ public function it_wont_call_the_missing_key_callback_when_the_translation_exist

$this->assertEquals('en value', trans('file.key'));
}

#[Test]
#[UsesVendor]
public function it_can_load_default_file_translations_from_the_framework(): void
{
// When using the UsesVendor attribute, refresh the application to prevent container resolution errors,
// such as "Illuminate\Contracts\Container\BindingResolutionException: Target class [config] does not exist".
$this->refreshApplication();

$this->assertEquals('The provided password is incorrect.', trans('auth.password'));
$this->assertEquals('Next »', trans('pagination.next'));
$this->assertEquals('Your password has been reset.', trans('passwords.reset'));
$this->assertEquals('The :attribute field must be accepted.', trans('validation.accepted'));
}

#[Test]
#[UsesVendor]
public function it_can_override_default_file_translations_from_the_framework(): void
{
// When using the UsesVendor attribute, refresh the application to prevent container resolution errors,
// such as "Illuminate\Contracts\Container\BindingResolutionException: Target class [config] does not exist".
$this->refreshApplication();

$this->assertEquals('Custom - The :attribute field must be a valid URL.', trans('validation.active_url'));
}
}
1 change: 1 addition & 0 deletions tests/fixtures/lang/en/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

return [
'required' => 'The :attribute field is required.',
'active_url' => 'Custom - The :attribute field must be a valid URL.',
];
Loading