chinleung / laravel-multilingual-routes

A package to handle multilingual routes in your Laravel application.
https://github.com/chinleung/laravel-multilingual-routes-demo
MIT License
401 stars 25 forks source link

Prefixed routes do not localize the URI #75

Closed jobara closed 1 year ago

jobara commented 1 year ago

Describe the bug

The URI isn't properly localized when a the routes are use a prefix defined in a group. The outputted routes will use the unlocalized URI

To Reproduce Say you define a route such as:

Route::prefix('test')
    ->group(function () {
        Route::multilingual('route', function () {
            return 'test';
        });
    });

And have a French translation file at resources/lang/fr/routes.php with something like:

<?php

return [
    'test/route' => 'teste/french-route',
];

The routes available are:

Expected behavior

The route should be localized based on the translation file. With the above sample one would expect the following routes.

Additional context

If the routes are defined without the prefix and group they are localized correctly. e.g.:

Route::multilingual('/test/route', function () {
    return 'test';
});
chinleung commented 1 year ago

Hey @jobara,

Sorry for the late response. I've totally missed the notification here. I'll have a look at this this week. 😄

chinleung commented 1 year ago

@jobara I've fixed this in https://github.com/chinleung/laravel-multilingual-routes/releases/tag/v4.0.1. 😄

Let's say you have something like this:

// routes/web.php

Route::prefix('prefix')->group(function () {
    Route::multilingual('test', function () {
        return 'Hello World';
    });
});

You can now translate the grouped prefix like this:

// lang/fr/routes.php

return [
    'prefix/test' => 'prefixe/teste',
];
jobara commented 1 year ago

@chinleung thank you so much for the fix and new release!