Skip to content

Prefix to route names #472

Discussion options

You must be logged in to vote

@CosmicodeStudio if I were you I would wrap the route() function in your own helper to pass the locale in when you call it, something like this:

// assuming `locale` is available globally
const locale = 'pt';

const localeRoute = (name, params, absolute, config) => {
    return route(`${locale}.${name}`, params, absolute, config);
}

localeRoute('users.show'); // will return the result of `route('pt.users.show')`

For current() you can probably use wildcards, route().current('*.users.show') should work. If you don't want to do that you could create another wrapper similar to the one above but for route().current().

Let me know if that works!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by bakerkretzmar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #471 on October 06, 2021 16:11.