Laravel Language Switcher
Вставка
- Опубліковано 27 жов 2024
- We build a language switcher in Laravel using the Vue component we built in the last video. We first take a look at localization in Laravel, then we use some middleware so the locale/language can be updated in our routes.
GitHub Repo: github.com/dre...
LINKS
My courses: codewithdre.com
Sign up for my newsletter: andremadarang.c...
My website: andremadarang.com
Twitter: / drehimself
GitHub: github.com/dreh...
CodePen: codepen.io/dreh...
Your voice is so soft/nice that I actually fell asleep only woke up because of the music at the end. Now I gotta rewatch the video.
Haha that's his way of getting more watch time on his videos
Thanks, this was very easy to follow and understand! Localization in my project done in less than 30 mins :)
Thank you Andre, we're learning a lot from you
You helped me a lot on fixing in middleware, calling route should be having two parameters, and how the language switcher could work! Thank you so much!!! 😍
Hi Andre, i have one tiny question. In your example you don't show how to use this language switcher (and Route::currentRouteName()) with some CRUD. I have some parameter to pass into my URL, and the "currentRouteName" throw exception with "missing required parameter", i don't understand how to resolve this problem :/ Could you help me ? regards
Thx, you helped me a lot. I used the AdminLte menu, I included the MenuBuilder on the middleware it works perfectly
It's really good for helping anyone Laravel developer. I appreciate you. Thank you so much
thanku very much i have stuck within 3 day but finally i got the solution thanku sir
RU
This link is not working with Route::get('/{id}', 'PostController@detail')->name('post_detail'); kind of routes. Is there other way to define href?
I just came up on this issue and can't figure out how to fix it.. Did you manage to find a workaround?
@@alex1236035 fixed on github repo and also posted on video comments hope it helps, happy coding
Hi Andre your video is great help however when I do {{route(Route::currentRouteName(), 'en')}} I get the error Route [] not defined. Can you help me with that
Finally a good explained video! Thanks dude!
awesome tutorial sir , Thank you very much sir
please upload more video's about Laravel
Very good Andre! Thank you for your help.
very clear and : followed your video ... it work ! thank you !
Great tutorial! Just I have problems with Email Verification...
thanks for all of your tutorials :) you make a great job!
Thanks for watching!
@@drehimself welcome. your tutorials really helpful for us
Thanks for all your tutorials
Thanks Andre. What if you have large pieces of text?
Hey, how do you use laravel localization inside of vue files? Shouldn't it be that way in the first place to keep everything frontend?
keep going andre your videos very good
You have a beautiful Bob Ross voice.
The best tutorial i have been found. Thanks Man
Thank you Andre.
Thanks a lot, great tutorial!
Thank you! thas was a really good tutorial, I have a question: why is it better to use VueJs instead of just HTML ?
thanks for all of your tutorials. :)
The question arose, why not use browser cookies to store the current language and not be tormented with the entries in each route? Or does it somehow affect SEO?
2:14 second, the language is not changing, i am following exact instructions! any solution?
Thanks for this great tutorial. Everything works until npm run watch. After i run this i get an error.
The error massage is:
ERROR in ./resources/js/app.js
Module not found: Error: Can't resolve ''vue in resources/js/app.js
Can you help me with that?
Thank you!
Thank you Andre for this video
I want to use Laravel Language Switcher in the blade and the component of vuejs, is that possible?
Thank you very much :)
Hi, how can I translate the routes with this package? I've been searching the net for a while and I can't handle it.
Thank You Andre.
currentRouteName - only works routes with no parameters , how can I make dynamic ?
Hi ! Have you figured it out ? I have the same situation here
Please, if we have content for Fr and other content for En, both are stored in database; How we can manage this?
Thank you and have nice time ;
i have problem when i use route(Route:currentRouteName(), 'en') i get Route [] not defined please help
Hi, did you figure it out? I am getting the same issue
Thank you Andre !
Will this work with articles from database ? A column fr and another en in posts table maybe ?
No, for database translations check out this package: github.com/spatie/laravel-translatable
Hi Andre,
thank you for this very cool video.
One question :
i get :
Missing required parameter for [Route: password.reset] [URI: {language}/password/reset/{token}] [Missing parameter: language]
when i click to send reset password email.
i have this in my email.blade.ph :
what do i wrong ?
Hey bud i just submited a fix for this on the video comments and on the github repo i hope it helps u! happy coding
Is it possible to access data from a lang file in another lang file? For example I have an address repeated multiple times in different lang files but I want to reference the a single point of truth. Is this possible?
Very awesome, Thank you so much
Morocco
Hi. Thanx for great expression. My question about 10:30. if i write ..../en (on url) language changes to en. İf i write .../fr language chnges to french. ok it is good. But if i write dummy parameter ..../qwerty my page turn the original language and url remains the .../qwerty . How can i do ? How can filter to url only with languge parameter.
please send me the link of your last video
language switcher in Laravel using the Vue component
thanks
Amazing package ❤
Thanks for tutorials :)
How can I hide the default locale, So that the default locale is accessible by
/home
as well as
/en/home
Thanks Mr.Andre useful video, but there's one issue when i switch the lang it work properly but when i click on the browser back button it take me to the previous page (with the previous lang ) without applying the new Selected lang
Useful video for me.
But how you have inserted the icons in the input fields of the registration form ? I don't have see in your blade views...
It's his OS Macintosh
🤦♂️
Haha yeah, it's the Lastpass chrome extension that adds those icons.
hey, thanks for the video ! however, i have an issue with last step, to add the visual dropdown using Vue.
so, I have the LanguageSwitcher.vue with the correct content, I have the app.js with the correct component added, and in my blade file I have the language-switcher tag, but nothing appears on the frontend....even when replacing the content of the LanguageSwitcher.vue to the "test" version...is there something I am missing here ? thanks for your help !
nevermind, found it ! i had to set a css ID to correspond to "app" as set in the app.js
bro i am getting problem in changing the locale it sets to default
where is the {language} parameter stated at?
I need some help. when i write EN it won't work. it say Route [] not defined.
You need to use named routes, make sure that you're current route name has a ->name("some.name")
@@alex1236035 Thanks, now it's working. :)
@@alex1236035 Hey man i having problem again adding an edit button. It say missing parameters i tried too many way but not work... Example: Editar hope you can help, i cannot nothing about it on laravel docs
@@IsaacRosarioDurantecnicomp I had the same problem back when I wanted to pass additional parameters on GET requests. That's because the language switcher shown in the video isn't configured to take additional params and it will always throw an error.
I asked this on stackoverflow and the solution helped me:
stackoverflow.com/questions/62607673/laravel-language-switcher-pass-additional-parameters-to-a-route
@@alex1236035 Thanks for the information, i will check it out
i have a problem to install laravel e commercer can u help me ?
this is fira code font in the text editor?
Great tutorial, thank you! Will be awesome if we can see the same but with React.js, I think it's challenging!
Now you could do it with laravel 8 inertia/vue
Thanks , i have question if i want the main route / have a greek language , and under this in /en request to english locale how can doit that ?
If you mean that you want Greek to be the default language of your website... You can set the locale and the fallback_locale to Greek in config/app.php. Hope that is an answer you can work with.
great video. , wich icon theme have you installed?
The one that comes with Material Theme
Route [] not defined "route(Route::currentRouteName()" , Laravel 7
Did you solve this issue?
@@fitimfejzullahu
@if(Route::currentRouteName())
English
|
Türkçe
@else
English
|
Türkçe
@endif
nice
❤❤❤❤
wrong Prefix&middleware method in 2023. register middlware in protected $routeMiddleware not in $middleware and you have to use ['prefix' => 'post', 'middleware' => ['write here keyword from routemiddleware']]
But this method makes me not able to pass any regular expression inside the route, except for the language
example this is my code I go to Url localhost:8000/en/9
route:
Route::group([
'prefix' => '{locale}',
'where' => ['locale' => '[a-zA-Z]{2}'],
'middleware' => 'setLocale'], function() {
Route::get('/{id}','pageController@test');
});
Controller:
public function test ($id){
$myid = $id;
return view('test',compact('myid'));
}
View:
{{dd($myid)}}
Result in browser "en"
Hey I have the same problem did you solve it??
@@boularhrassnisrine5220 I have the same problem did you solve it
@@hamzaz6989 hello I tried another solution I made translation in session it s easy and a lot better try to look for it
thanx
❤️
20:00
you will need to use sessions , App::setLocale is not persistent.
That could be persistent as long as there is {lang} parameter in URI in every request.
15.01
Thank you Andre!
nice