Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize default locale for urls #14

Closed
jsanchezgr opened this issue Nov 21, 2019 · 4 comments
Closed

Customize default locale for urls #14

jsanchezgr opened this issue Nov 21, 2019 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@jsanchezgr
Copy link

Context

I have a site with the following locales: es (default), en (generic) and pt. The url structure should be as follows:

/nosotros //es
/en/about-us //en
/pt/sobre-nos //pt

That can be achieved by setting app.fallback_locale = 'es', however I need english to be the generic language.

Problem

Taking a look to the code, this function forces the default (hidden) url prefix, to be the same as the fallback_locale language.

protected function generatePrefixForLocale(string $key, string $locale) : ?string
    {
        if ($key == '/') {
            return null;
        }

        if ($locale != config('app.fallback_locale')) {
            return $locale;
        }

        return config('laravel-multilingual-routes.prefix_fallback')
            ? $locale
            : null;
    }

Potential fix

Just by adding a laravel-multilingual-routes.default_locale config param should do the trick. If you're happy with that, I can provide a PR.

Thanks

@chinleung
Copy link
Owner

@jsanchezgr Yeah sure I'd accept a PR for that. Might as well change the prefix_fallback to prefix_default. 😄

@chinleung chinleung added the enhancement New feature or request label Nov 26, 2019
@chinleung
Copy link
Owner

@jsanchezgr I will have time to fix this issue this weekend. Can you let me know if you are about to finish this? Don't want to waste your effort! 😅

@jsanchezgr
Copy link
Author

jsanchezgr commented Nov 27, 2019 via email

@chinleung chinleung self-assigned this Nov 27, 2019
@chinleung
Copy link
Owner

@jsanchezgr The configuration is now available in v1.4.0. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants