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...

КОМЕНТАРІ • 102

  • @Gibbu_
    @Gibbu_ 4 роки тому +9

    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.

    • @ironspider9026
      @ironspider9026 3 роки тому

      Haha that's his way of getting more watch time on his videos

  • @bobross2404
    @bobross2404 2 роки тому +2

    Thanks, this was very easy to follow and understand! Localization in my project done in less than 30 mins :)

  • @two-zero
    @two-zero Рік тому

    Thank you Andre, we're learning a lot from you

  • @ftr_unama4065
    @ftr_unama4065 2 роки тому

    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!!! 😍

  • @silverblack179
    @silverblack179 4 роки тому +7

    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

  • @idgs.carlosguizar4383
    @idgs.carlosguizar4383 Рік тому

    Thx, you helped me a lot. I used the AdminLte menu, I included the MenuBuilder on the middleware it works perfectly

  • @md.abdullahalnoman5071
    @md.abdullahalnoman5071 3 роки тому

    It's really good for helping anyone Laravel developer. I appreciate you. Thank you so much

  • @busyfun3891
    @busyfun3891 Рік тому

    thanku very much i have stuck within 3 day but finally i got the solution thanku sir

  • @abylayomar416
    @abylayomar416 4 роки тому +5

    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?

    • @alex1236035
      @alex1236035 4 роки тому

      I just came up on this issue and can't figure out how to fix it.. Did you manage to find a workaround?

    • @NulledExp
      @NulledExp 2 роки тому

      @@alex1236035 fixed on github repo and also posted on video comments hope it helps, happy coding

  • @kishwerwali1878
    @kishwerwali1878 2 роки тому +1

    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

  • @jimishukurow2286
    @jimishukurow2286 3 роки тому

    Finally a good explained video! Thanks dude!

  • @sooriyakumarkarnan7885
    @sooriyakumarkarnan7885 3 роки тому

    awesome tutorial sir , Thank you very much sir
    please upload more video's about Laravel

  • @marfdiogo
    @marfdiogo 4 роки тому

    Very good Andre! Thank you for your help.

  • @volkerhoffmann7381
    @volkerhoffmann7381 3 роки тому

    very clear and : followed your video ... it work ! thank you !

  • @nachobermudez8270
    @nachobermudez8270 4 роки тому +2

    Great tutorial! Just I have problems with Email Verification...

  • @ersonusaini
    @ersonusaini 5 років тому +1

    thanks for all of your tutorials :) you make a great job!

    • @drehimself
      @drehimself  5 років тому +2

      Thanks for watching!

    • @ersonusaini
      @ersonusaini 5 років тому +1

      @@drehimself welcome. your tutorials really helpful for us

  • @ieee5998
    @ieee5998 5 років тому

    Thanks for all your tutorials

  • @marcuu5
    @marcuu5 4 роки тому +1

    Thanks Andre. What if you have large pieces of text?

  • @arturmuellerromanov4438
    @arturmuellerromanov4438 3 роки тому +1

    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?

  • @Mohamed-wd1cv
    @Mohamed-wd1cv 5 років тому

    keep going andre your videos very good

  • @martijnveerman7916
    @martijnveerman7916 3 роки тому

    You have a beautiful Bob Ross voice.

  • @IsaacRosarioDurantecnicomp
    @IsaacRosarioDurantecnicomp 4 роки тому

    The best tutorial i have been found. Thanks Man

  • @msdeav
    @msdeav 5 років тому +1

    Thank you Andre.

  • @marcwampfler2203
    @marcwampfler2203 3 роки тому

    Thanks a lot, great tutorial!

  • @gigatodadze9447
    @gigatodadze9447 3 роки тому

    Thank you! thas was a really good tutorial, I have a question: why is it better to use VueJs instead of just HTML ?

  • @jainnersalas381
    @jainnersalas381 5 років тому

    thanks for all of your tutorials. :)

  • @tmdan91
    @tmdan91 4 роки тому

    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?

  • @sairaahmed9820
    @sairaahmed9820 2 роки тому

    2:14 second, the language is not changing, i am following exact instructions! any solution?

  • @bieberbalazs6826
    @bieberbalazs6826 4 роки тому +1

    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!

  • @ahmedbouchboua7449
    @ahmedbouchboua7449 4 роки тому +1

    Thank you Andre for this video
    I want to use Laravel Language Switcher in the blade and the component of vuejs, is that possible?

  • @mohammedeisa5997
    @mohammedeisa5997 3 роки тому

    Thank you very much :)

  • @cristianilisei96
    @cristianilisei96 3 роки тому

    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.

  • @Somcoders
    @Somcoders 4 роки тому

    Thank You Andre.
    currentRouteName - only works routes with no parameters , how can I make dynamic ?

    • @IspasTeodora
      @IspasTeodora 3 роки тому +1

      Hi ! Have you figured it out ? I have the same situation here

  • @aomo5293
    @aomo5293 4 роки тому

    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 ;

  • @malikalnabouli8289
    @malikalnabouli8289 3 роки тому

    i have problem when i use route(Route:currentRouteName(), 'en') i get Route [] not defined please help

    • @kishwerwali1878
      @kishwerwali1878 2 роки тому

      Hi, did you figure it out? I am getting the same issue

  • @julienSibille
    @julienSibille 5 років тому

    Thank you Andre !
    Will this work with articles from database ? A column fr and another en in posts table maybe ?

    • @drehimself
      @drehimself  5 років тому +1

      No, for database translations check out this package: github.com/spatie/laravel-translatable

  • @vohoff
    @vohoff 3 роки тому

    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 ?

    • @NulledExp
      @NulledExp 2 роки тому

      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

  • @devjam23
    @devjam23 4 роки тому

    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?

  • @aomo5293
    @aomo5293 4 роки тому

    Very awesome, Thank you so much
    Morocco

  • @fatihu453
    @fatihu453 4 роки тому

    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.

  • @muhammadmukarram9242
    @muhammadmukarram9242 4 роки тому

    please send me the link of your last video
    language switcher in Laravel using the Vue component
    thanks

  • @icrmsoftware59
    @icrmsoftware59 4 роки тому

    Amazing package ❤

  • @107shahfaisal
    @107shahfaisal 4 роки тому

    Thanks for tutorials :)

  • @DirectVisaKSA
    @DirectVisaKSA 4 роки тому

    How can I hide the default locale, So that the default locale is accessible by
    /home
    as well as
    /en/home

  • @farouklilou4527
    @farouklilou4527 4 роки тому

    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

  • @pakka63
    @pakka63 5 років тому

    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...

    • @AhmadHassan-ss5un
      @AhmadHassan-ss5un 5 років тому

      It's his OS Macintosh

    • @pakka63
      @pakka63 5 років тому

      🤦‍♂️

    • @drehimself
      @drehimself  5 років тому

      Haha yeah, it's the Lastpass chrome extension that adds those icons.

  • @MGKday
    @MGKday 5 років тому

    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 !

    • @MGKday
      @MGKday 5 років тому

      nevermind, found it ! i had to set a css ID to correspond to "app" as set in the app.js

  • @muhammadahmed9475
    @muhammadahmed9475 4 роки тому

    bro i am getting problem in changing the locale it sets to default

  • @twenty9str498
    @twenty9str498 4 роки тому

    where is the {language} parameter stated at?

  • @IsaacRosarioDurantecnicomp
    @IsaacRosarioDurantecnicomp 4 роки тому

    I need some help. when i write EN it won't work. it say Route [] not defined.

    • @alex1236035
      @alex1236035 4 роки тому +1

      You need to use named routes, make sure that you're current route name has a ->name("some.name")

    • @IsaacRosarioDurantecnicomp
      @IsaacRosarioDurantecnicomp 4 роки тому

      @@alex1236035 Thanks, now it's working. :)

    • @IsaacRosarioDurantecnicomp
      @IsaacRosarioDurantecnicomp 4 роки тому

      @@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

    • @alex1236035
      @alex1236035 4 роки тому

      @@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

    • @IsaacRosarioDurantecnicomp
      @IsaacRosarioDurantecnicomp 4 роки тому

      @@alex1236035 Thanks for the information, i will check it out

  • @liok8233
    @liok8233 5 років тому

    i have a problem to install laravel e commercer can u help me ?

  • @OnlineGamePlaying
    @OnlineGamePlaying 5 років тому

    this is fira code font in the text editor?

  • @asterisk007
    @asterisk007 5 років тому +1

    Great tutorial, thank you! Will be awesome if we can see the same but with React.js, I think it's challenging!

  • @hyiping5926
    @hyiping5926 3 роки тому

    Now you could do it with laravel 8 inertia/vue

  • @alexanderanastasiadis9284
    @alexanderanastasiadis9284 4 роки тому

    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 ?

    • @BurtDS
      @BurtDS 4 роки тому

      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.

  • @mtzrmzia
    @mtzrmzia 5 років тому

    great video. , wich icon theme have you installed?

    • @drehimself
      @drehimself  5 років тому

      The one that comes with Material Theme

  • @atanwt9637
    @atanwt9637 4 роки тому

    Route [] not defined "route(Route::currentRouteName()" , Laravel 7

    • @fitimfejzullahu
      @fitimfejzullahu 4 роки тому

      Did you solve this issue?

    • @atanwt9637
      @atanwt9637 4 роки тому +2

      ​@@fitimfejzullahu
      @if(Route::currentRouteName())
      English
      |
      Türkçe
      @else
      English
      |
      Türkçe
      @endif

  • @TuanNguyen-bk7yc
    @TuanNguyen-bk7yc 4 роки тому

    nice

  • @mohammadkhodadadi6018
    @mohammadkhodadadi6018 7 місяців тому

    ❤❤❤❤

  • @tornikerikiashvili6174
    @tornikerikiashvili6174 Рік тому

    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']]

  • @sekosam5516
    @sekosam5516 5 років тому

    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"

    • @boularhrassnisrine5220
      @boularhrassnisrine5220 4 роки тому

      Hey I have the same problem did you solve it??

    • @hamzaz6989
      @hamzaz6989 4 роки тому

      @@boularhrassnisrine5220 I have the same problem did you solve it

    • @boularhrassnisrine5220
      @boularhrassnisrine5220 4 роки тому

      @@hamzaz6989 hello I tried another solution I made translation in session it s easy and a lot better try to look for it

  • @najmeddinhaidar9641
    @najmeddinhaidar9641 5 років тому

    thanx

  • @Jesus-mu4ix
    @Jesus-mu4ix 5 років тому

    ❤️

  • @リョウ-w1z
    @リョウ-w1z 3 роки тому

    20:00

  • @SebastianPerezG
    @SebastianPerezG 5 років тому

    you will need to use sessions , App::setLocale is not persistent.

    • @johnyonardpauly5601
      @johnyonardpauly5601 5 років тому

      That could be persistent as long as there is {lang} parameter in URI in every request.

  • @TheHayk1997
    @TheHayk1997 2 роки тому

    15.01

  • @persianabad599
    @persianabad599 5 років тому

    Thank you Andre!

  • @software_engineer_semh
    @software_engineer_semh 5 років тому

    nice