Giter Site home page Giter Site logo

Default subdomain FR about laravel-tongue HOT 9 CLOSED

pmochine avatar pmochine commented on June 14, 2024
Default subdomain FR

from laravel-tongue.

Comments (9)

pmochine avatar pmochine commented on June 14, 2024

First, thank you for your nice words! And now to your issue. I just tested a simple Laravel demo and even app()->getLocale() shows the wrong language. That's super weird! I will find it out!

from laravel-tongue.

pmochine avatar pmochine commented on June 14, 2024

@rseon OK I think I know what's up.

So this can lead to a discussion on what is right and what is wrong...

The solution of your problem is to set your 'fallback_locale' => 'fr'

Here is why: https://github.com/pmochine/Laravel-Tongue/blob/master/src/Tongue.php#L89

If we don't find any locale in your URL, we assume we need to go to your fallback main language. That is in your case fr. We assume that your fallback language will always have a translation.

'locale' => 'fr', is with this package useless because we try to detect the language first via the browser or the cookies. And the value is always variable. That means app()->getLocale() shows us always a different locale

Tell me what you think

from laravel-tongue.

rseon avatar rseon commented on June 14, 2024

I've tried with another language es on another subdomain es.my_domain.dv. The funny thing is :

So without subdomain, the last locale is used (cookie I think ?)
I've tried with 'fallback_locale' => 'fr', no change.

My routes are not translated and {{ dialect()->current('fr') }} returns http://fr.my_domain.dv.

I continue to investigate.

from laravel-tongue.

pmochine avatar pmochine commented on June 14, 2024

Do you have the middleware active? So that the redirection is working properly?

Because in your example when you go back to your domain without the subdomain it always has the latest locale you have used

from laravel-tongue.

rseon avatar rseon commented on June 14, 2024

When I set the middleware globally in the RouteServiceProvider@mapWebRoutes, I'm redirected to en.my_domain.dv.
If I set it on the route file (using Route::group([ 'middleware' => [ 'speaks-tongue' ]], function() { ... });, only the localized routes are redirected to the en subdomain.

from laravel-tongue.

rseon avatar rseon commented on June 14, 2024

Another funny thing is if I vist fr.my_domain.dv, I'm redirected to my_domain.dv and locale is correct...

But from another language, {{ dialect()->current('fr') }} returns http://fr.my_domain.dv without localized route.

I'm lost ^^

from laravel-tongue.

pmochine avatar pmochine commented on June 14, 2024

@rseon Okay, could you do me a favour. Create a fresh Laravel project and install my package. And try to create a minimal Laravel package, so I can see your problems.
And if possible, write down the issues you have again in a readme file, so I can work on those.

Thank you :)

p.S. sorry that I couldn't reply so soon, our city is completely locked down... funny times

from laravel-tongue.

rseon avatar rseon commented on June 14, 2024

@pmochine You can find the test repo there : https://github.com/rseon/laravel-tongue-test

Thanks for your review, and good luck for these funny times !

from laravel-tongue.

pmochine avatar pmochine commented on June 14, 2024

@rseon So thank you for your test repo. You find a pull request where I have change some things.

And thank you, because of you I found some small bugs. dialect()->redirectUrl(route('home'), 'fr') This part was indeed a bug. I am actually not sure why I wrote this like that. There are not options like this. You should have used translate.

New patch coming soon

from laravel-tongue.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.