Framework: LengthAwarePaginator (Pagination JSON) don't use translations/locale.

Created on 6 Oct 2020  路  6Comments  路  Source: laravel/framework


  • Laravel Version: 8
  • PHP Version: 7.3
  • Database Driver & Version:

Description:

Simple, the code in src/Illuminate/Pagination/LengthAwarePaginator.php line 118, 122 don't use locale.

})->prepend([
            'url' => $this->previousPageUrl(),
            'label' => 'Previous',
            'active' => false,
        ])->push([
            'url' => $this->nextPageUrl(),
            'label' => 'Next',
            'active' => false,
        ]);

It should use the locale, something like:

'label' => __('pagination.next'),

Thanks.

Steps To Reproduce:

1- Install Laravel with other than English locale
2- Use the pagination function for Collection and see the result in JSON

All 6 comments

Sure, PR it.

@taylorotwell Great, PR is open. https://github.com/laravel/framework/pull/34710

This PR for this had to be reverted because it used an IlluminateFoundation helper (__) in a component. That can cause problems for people using it outside of Laravel. So, we would have to find another way to solve this.

@taylorotwell What will be the better way then, a function check ? Or other translations methods ? Default values ?

Checking if the function exists is probably reasonable middle ground, yeah.

New PR open for this. https://github.com/laravel/framework/pull/34714
Thanks.

Was this page helpful?
0 / 5 - 0 ratings