.NET MAUI Blazor Switch Language In-App: Here's How!

Поделиться
HTML-код
  • Опубликовано: 7 сен 2024
  • НаукаНаука

Комментарии • 50

  • @jfversluis
    @jfversluis  2 года назад +1

    Curious on how to localize your .NET MAUI Blazor app in the first place? Check out this video: ruclips.net/video/EHoO9hG-Uzo/видео.html

    • @andrewg.a.7661
      @andrewg.a.7661 2 года назад +2

      and how about localizing a non-Blazor MAUI app?

    • @n1ghtm4re62
      @n1ghtm4re62 2 года назад

      @@andrewg.a.7661 Yes that we want to know ! :D

    • @jfversluis
      @jfversluis  2 года назад +1

      Look up how to do it for Xamarin.Forms, it will be the same 🤓

    • @n1ghtm4re62
      @n1ghtm4re62 2 года назад

      @@jfversluis Done and it works ! Except on Windows, I have refresh problems 😫

  • @aliciathomas456
    @aliciathomas456 2 года назад +1

    Thank you for sharing making this video and sharing it with us. this kind of video helps those business owners who have a business and want to develop mobile and web applications but have no knowledge of technology and coding and so keep sharing this kind of video.

  • @MrLazyleader
    @MrLazyleader 2 года назад +1

    Thank you so much for this. I will implement this in my App. I'd set the default preference to device language instead of en-US, but that shouldn't be too difficult.

    • @jfversluis
      @jfversluis  2 года назад +1

      Just request whatever value is in those CultureInfo objects to see the device ones

  • @jlassen741
    @jlassen741 2 года назад +1

    Hi Gerald,
    as always - a great video!
    Is it possible, that you have a demo for a .NET MAUI App in your repository?
    Couldn't find anything in the web. All examples are for BLAZOR. Thank you!

  • @kusoft9001
    @kusoft9001 8 месяцев назад

    Hi Gerald, great stuff thanks for sharing such a great tutorials. I am looking for a solution of offline sync functionality with .net MAUI. It would be great if you share something related to creating manual offline synchronization with Rest API and .Net MAUI using SQLite s3db. Thanks

  • @tofu1687
    @tofu1687 Год назад

    Great video to make translation easy - thanks !
    Now there's still the problem of the text format for date and decimal values that wont change
    The problem seems to be on the WebView2
    Does any one have a solution (that doesn't require to completetly redesign components) ?

  • @Tamer_Ali
    @Tamer_Ali 2 года назад

    Thanks Gerald for your awesome video.
    I hope you will explain how to change the direction of the app when switching the language too.

    • @jfversluis
      @jfversluis  2 года назад

      You should be able to set the RTL property for that :)

  • @frankleib4176
    @frankleib4176 Год назад +1

    if I switch the language, I have to start the app new,only after the restart of the app it will change. Do you have a idea for this, because my plan is to change the language after click and not after restart ;)

    • @100-cias
      @100-cias Год назад

      Same for me. I think the the thread of the app is different, so when you change page, culture changes are lost. I had to restart the app for the changes to be applied.

    • @emplol1622
      @emplol1622 Год назад

      Have you found any solution for this ?

  • @Leqsus5
    @Leqsus5 2 года назад +1

    thank you very much!

  • @stijnvanhoecke4753
    @stijnvanhoecke4753 2 года назад

    Nice video :) although... for language selection... it is a UX guideline to show the name of the language in its own language, since people who don't read chinese for instance, won't know what language to pick from if all of them are written in chinese. The more user-friendly approach is to only write the language "chinese" in chinese, and other languages in their respective language. How would we go about that? The expectation is a list with "English, Nederlands, Francais, ..."

    • @jfversluis
      @jfversluis  2 года назад

      Is that from the great UX bible that everyone should adhere to? 😉 Good suggestion! Shouldn't be that hard, I think the CultureInfo object has a property that will always have the English name. Use that for your list and you're golden!

    • @stijnvanhoecke4753
      @stijnvanhoecke4753 2 года назад

      @@jfversluis aaah but that's the thing, I don't always want the English name either, because we can't assume that everyone knows English just the same way as we can't assume everyone knows Chinese ;)
      Ideally I want all languages displayed in their own native language, so speakers of that language recognise the value they need to select in the list. Dutch should in that case be represented by "Nederlands" (in every UI language), French should be represented by "Français", Finnish by "Suomi", Chinese in chinese characters, and so on. I could hard-code the list to always use these values but then the system isn't very dynamic... Does every culture info have a display value in its own language? Or how should we go about that?

    • @johankrantz8478
      @johankrantz8478 2 года назад +2

      Use @culture.NativeName in the select list instead of Name. :)

    • @stijnvanhoecke4753
      @stijnvanhoecke4753 2 года назад

      @@johankrantz8478 that's so useful! I didn't know that property existed :D thanks a lot!

  • @alialshreef2874
    @alialshreef2874 Год назад

    Thank you so much .🤗

  • @Mielesplayz
    @Mielesplayz Год назад

    is there a way to do this in a normal .net maui application?

  • @pianoschmiddy
    @pianoschmiddy 2 года назад

    I am using one xaml page that uses two blazor components that both use the localization as you described. One of the components does the actual language settings. The component that does do the language settings gets set to the new language automatically. The other component doesn't get updated. I have to restart the app for it to reflect the language changes. Any ideas how I can automatically update the other components too?

    • @Martinedo_
      @Martinedo_ 2 года назад +2

      yes, because the parent component is already preloaded. In my solution I informed the user, that the langugae will be updated in the next start of the app.. but I also would like to have an better solution for this.

  • @Neha-lh6ok
    @Neha-lh6ok 2 года назад

    I have downloaded the sample repository error faced while debug
    ```Error CS1061 'IServiceCollection' does not contain a definition for 'AddMauiBlazorWebView' and no accessible extension method 'AddMauiBlazorWebView' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?) MauiBlazorLocalizationSample (net6.0-android), MauiBlazorLocalizationSample (net6.0-ios), MauiBlazorLocalizationSample (net6.0-maccatalyst), MauiBlazorLocalizationSample (net6.0-windows10.0.19041)```
    can you please help to resolve this

    • @jfversluis
      @jfversluis  2 года назад

      Updated! Try again please! :D

    • @Neha-lh6ok
      @Neha-lh6ok 2 года назад

      @@jfversluis Still the same ! I am Using Visual Studio 2022 preview 17.2.0 2.1 version does it have anything to do with the preview version ?
      Severity Code Description Project File Line Suppression State
      Error CS1061 'IServiceCollection' does not contain a definition for 'AddMauiBlazorWebView' and no accessible extension method 'AddMauiBlazorWebView' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?) MauiBlazorLocalizationSample (net6.0-ios), MauiBlazorLocalizationSample (net6.0-maccatalyst), MauiBlazorLocalizationSample (net6.0-windows10.0.19041) Downloads\MauiBlazorDynamicLocalizationSample-main\MauiBlazorLocalizationSample\MauiProgram.cs 18 Active
      Severity Code Description Project File Line Suppression State
      Error CS1061 'IServiceCollection' does not contain a definition for 'AddBlazorWebViewDeveloperTools' and no accessible extension method 'AddBlazorWebViewDeveloperTools' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?) MauiBlazorLocalizationSample (net6.0-android), MauiBlazorLocalizationSample (net6.0-ios), MauiBlazorLocalizationSample (net6.0-maccatalyst), MauiBlazorLocalizationSample (net6.0-windows10.0.19041) Downloads\MauiBlazorDynamicLocalizationSample-main\MauiBlazorLocalizationSample\MauiProgram.cs 20 Active

    • @jfversluis
      @jfversluis  2 года назад

      Hm I might need to update the template more. There have been breaking changes in the templates.
      Create a new Blazor app yourself and copy over the code bits that have to do with the language selection

  • @comediehero
    @comediehero 2 года назад

    Can i use this technique in WPF as well?

    • @jfversluis
      @jfversluis  2 года назад +1

      You mean WPF with a BlazorWebView? It should!

  • @ilanmazuz
    @ilanmazuz 2 года назад

    Hi Gerald,
    i tried implementing this logic in my .net core razor pages app but it didn't work.
    Do you have a sample project for razor pages as well?
    Thanks a lot!

    • @jfversluis
      @jfversluis  2 года назад

      For regular Blazor it's a little different, check out the docs for it: docs.microsoft.com/aspnet/core/blazor/globalization-localization?view=aspnetcore-6.0&pivots=server#dynamically-set-the-culture-by-user-preference

    • @ilanmazuz
      @ilanmazuz 2 года назад

      @@jfversluis thanks so much for the reply! i am not using Blazor, i am using Razor page :)
      nevertheless, i had some similar work done in the past in the program.cs file with all the pipeline of adding localization, it just didn't work for some reason...
      i will keep researching. thanks a lot my friend!

    • @jfversluis
      @jfversluis  2 года назад

      Oh sorry! Misread that 😅 don’t have much experience with that. Hope you’ll figure it out!

    • @ilanmazuz
      @ilanmazuz 2 года назад

      @@jfversluis no worries, thank a lot :)

  • @cyrildouglas9262
    @cyrildouglas9262 2 года назад

    Thanks for this great video, how about the normal MAUI App (not MAUI blazor)?

    • @jfversluis
      @jfversluis  2 года назад +1

      I will probably do that at some point, but it shouldn't be any different than localizing your Xamarin.Forms app :)

    • @cyrildouglas9262
      @cyrildouglas9262 2 года назад

      @@jfversluis Thanks so much that would be great, I yet couldn't convince myself to use xamarin forms as I'm not happy with it's project architecture, so I'm wating for RC release of MAUI to start working on mobile.

    • @jfversluis
      @jfversluis  2 года назад +1

      @@cyrildouglas9262 Even though you might not be using Forms right now, you can still look up resources on how to do things and they should be easily transferable to .NET MAUI. Might be helpful when you start looking into .NET MAUI!

    • @cyrildouglas9262
      @cyrildouglas9262 2 года назад

      @@jfversluis Of course, thank you so much for pointing these out, I check some stuff in xamarin forms as well.

  • @yanaraldaghestani6305
    @yanaraldaghestani6305 2 года назад

    what amazing you are

  • @mohamadsoltani1982
    @mohamadsoltani1982 2 года назад

    awesome