Localization in .NET MAUI - Adding Multi-Language to Your Apps

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ส.ค. 2024
  • Just like any other .NET project you can localization your .NET MAUI apps with the use of resx resource files. In this video I will show you 3 ways, each one a slight improvement over the other, to add localization to your app and make your .NET MAUI app speak multiple languages.
    💝 Join this channel to get access to perks:
    th-cam.com/channels/ral.html...
    Disclaimer: this channel is done on personal title, in my free time, and not officially affiliated with or endorsed by Microsoft (my employer) in any way. Opinions and views are my own.
    🛑 Don't forget to subscribe to my channel for more cool content: th-cam.com/users/GeraldVerslui...
    🐦 Follow me on Twitter: / jfversluis
    🤝 Join the Discord server: / discord
    🔗 Links
    Sample Code Repo: github.com/jfversluis/MauiLoc...
    ResXManager: marketplace.visualstudio.com/...
    .NET MAUI Docs: docs.microsoft.com/dotnet/maui
    .NET MAUI Repository: github.com/dotnet/maui
    ⏱ Timestamps
    0:00 - Localization in .NET MAUI
    0:11 - What is Localization?
    0:53 - Add Resx Resource Files
    3:39 - Add Localization in XAML
    5:42 - Add Translated Resource Resx File
    8:09 - Dynamically Update Localization with LocalizationResourceManager
    11:19 - Use LocalizationResourceManager in XAML
    12:10 - Implement Switching Languages in Code
    13:23 - Translate Strings From Code, with Parameters!
    15:48 - DEMO FAIL!1!!
    16:14 - Fix the Demo!
    17:24 - Working Dynamic Swithing Demo
    18:05 - Write a XAML Markup Extension to Make it Easier!
    22:26 - AMAZING PLUGIN ALERT!
    🎥 Video edited with Camtasia (ref): techsmith.z6rjha.net/AJoeD
    🙋‍♂️ Also find my...
    Blog: blog.verslu.is
    Twitch: / jfversluis
    All the rest: jfversluis.dev
    #maui #localization #resx #dotnet #dotnetmaui
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 85

  • @jfversluis
    @jfversluis  ปีที่แล้ว +1

    Whoops! Look like I made a little mistake in editing... 🫣 Can you spot where?
    Looking for localization on your .NET MAUI Blazor app? I've got you covered, as always: th-cam.com/video/EHoO9hG-Uzo/w-d-xo.html

  • @cavanmcsweney869
    @cavanmcsweney869 27 วันที่ผ่านมา

    Great video Gerald, the last part about writing an XAML markup extensions is brilliant. Will save me so much time moving forward when having to write apps with multiple languages

    • @jfversluis
      @jfversluis  26 วันที่ผ่านมา

      They’re very powerful indeed! Glad it was useful!

  • @Pevi70
    @Pevi70 9 หลายเดือนก่อน +1

    Dank je wel, Gerald!
    Click
    Thanks, Gerald!

    • @jfversluis
      @jfversluis  9 หลายเดือนก่อน

      Haha you’re welcome!

  • @jewersp
    @jewersp ปีที่แล้ว +1

    I learned something again today. The markup extension approach is very neat, Gerald. Thank you for this. I might pick this up in one of my blog posts in the future.

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      Excellent! Please let me know when you post it!

    • @jewersp
      @jewersp ปีที่แล้ว

      @@jfversluis Sure, I'll send you a message!

  • @bassoons9974
    @bassoons9974 ปีที่แล้ว +1

    Thanks, well build up and explained!

    • @jfversluis
      @jfversluis  ปีที่แล้ว +1

      Glad it was helpful!

  • @marcmognol
    @marcmognol ปีที่แล้ว

    Hi! The way you pronounced @ 6:33 the R is perfect in French 😂😂 Bravo et merci.

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      😂 I almost never mix up Dutch with English! But decided to just let this one in. Glad I also speak French now!
      That reminds me, my French teacher would always say that my French tone was perfect but she couldn't understand a thing 😅

  • @mb72oz
    @mb72oz ปีที่แล้ว

    Thanks, Gerald, I'd definitely be interested in a follow-up video about the plugin mentioned at the end of this already-useful video.

    • @jfversluis
      @jfversluis  ปีที่แล้ว +2

      Coming! And I actually found another plugin so I might do a video about the two for comparison

    • @mohammedsadiq6953
      @mohammedsadiq6953 3 หลายเดือนก่อน

      @@jfversluis any news on this

  • @bashobbel3575
    @bashobbel3575 ปีที่แล้ว

    Cool , the last option is very nice

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      Yep that makes it nice and easy! And even better with the plug-in I mentioned because you don’t even need to do the work 😬

  • @andrewtruckle1695
    @andrewtruckle1695 ปีที่แล้ว

    Thanks for this interesting tutorial. I know that I asked for something about localization. I am also interested in the follow up video you referred too concerning the plugin for resource management.

    • @jfversluis
      @jfversluis  ปีที่แล้ว +1

      Glad it was helpful! The rest is coming soon!

  • @pushanroychowdhury5741
    @pushanroychowdhury5741 ปีที่แล้ว

    Thanks Gerald for this. I have a request: can you please make a video on how to create a custom control with Handlers ?

  • @rameezimtiaz6274
    @rameezimtiaz6274 10 หลายเดือนก่อน

    Very useful video Gerald..! I I'd love if you make a video on "Connection with Google Drive API, upload/ download files to G Drive in .NET MAUI", as I search a lot and can't find any helpful resource. Would be super thankful to you. 🙂

  • @Tamer_Ali
    @Tamer_Ali ปีที่แล้ว

    Hi Gerald,
    Thanks for the awesome video
    I think Community Toolkit has a localization package I used it long time ago with Xamarin Forms.
    How to change the direction of the app?

  • @ka4ep
    @ka4ep ปีที่แล้ว

    At last a neat and working solution instead of (Application.Current as App).MainPage = new AppShell();

  • @its-AliRaza
    @its-AliRaza ปีที่แล้ว

    Thanks, everything working fine. I have a question that is this possible that we have list of languages in MVVM and we have added the translation in resource file against keys and list bind to collection view. Can we get the translation of that keys through bindings ?

  • @frankpohl5620
    @frankpohl5620 ปีที่แล้ว

    This is nice for the strings that are used in the program. How can the DisplayName for the app be localized? In UWP it was possible to define a reference with ms-resource:. For example putting ms-resource:AppTitle in the field "Display name" in the manifest would use the strings defined as AppTitle in the resources. But I could not get that working in .NET MAUI. Can you point me in the right direction?

  • @vitaliinnest
    @vitaliinnest ปีที่แล้ว

    thx for the solution

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      You're most welcome!

  • @pr0_secrurity876
    @pr0_secrurity876 ปีที่แล้ว

    Hello Gerald, can you make a video about inApp purchase for android/ios/windows/mac

  • @user-ir2fh3zl7o
    @user-ir2fh3zl7o ปีที่แล้ว

    Great! Thank you. I use it.

    • @jfversluis
      @jfversluis  ปีที่แล้ว +1

      Great! Good luck!

  • @singhwong
    @singhwong ปีที่แล้ว

    Your video helped me a lot, I want to know how to localize app name in Maui.

  • @gwisekor
    @gwisekor ปีที่แล้ว

    goooooood

  • @mohammedalsabahii2
    @mohammedalsabahii2 ปีที่แล้ว +1

    Awesome video we are waiting this video ,, actually there's a question some languages need to change also loading lable text from left to right or right to left so using this tool can i change FlowDirection as runtime from mvvm ?! ,, thank you for this helping video wish you a good day

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      Ah that's a great question! I guess you'd also have to save some information about if it's a RTL language and switch that property for your app accordingly.

    • @mohammedalsabahii2
      @mohammedalsabahii2 ปีที่แล้ว

      @@jfversluis thank you i will

  • @markoliberty7581
    @markoliberty7581 6 หลายเดือนก่อน

    How do you change the datetime settings of a datetime picker? Month, day names stay the same, they dont change like that.

  • @svez88
    @svez88 ปีที่แล้ว

    Halo from Indonesia. Gerald , thanks for the share good information, i want to know more about ResXManager and the AI, please introduce us how to implement that , God bless =)

  • @manfredrohleder4674
    @manfredrohleder4674 ปีที่แล้ว

    Hi Gerald, how can I localize the info.plist?

  • @torres0945
    @torres0945 ปีที่แล้ว

    And if we have our app opened and change language from android system how we can get this event?

  • @hungchip
    @hungchip หลายเดือนก่อน

    why not use MVVM?
    How should I write the last 2 methods in LocalizationResourceManager file with MVVM?

  • @IvanKozlov-re9ez
    @IvanKozlov-re9ez ปีที่แล้ว

    Hi Gerald! Thanks for your video! I have a question. Can we localize MAUI controls like Picker. What if I want to change language for "Cancel" button?

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      This should help with that: blog.verslu.is/xamarin/xamarin-forms-xamarin/localization-default-ios-controls/

  • @vitalikdm0685
    @vitalikdm0685 ปีที่แล้ว

    For those who has a VS compilation error . Change resource file property Build Action from Android Resource (that is set my default after creation in my case), just change it to Embedded Resource

  • @JasonPurkiss
    @JasonPurkiss ปีที่แล้ว +1

    I think I went a bit nuts when I found out you could do this a few years ago as I think adding 40 languages was a bit much and stopped when trying to add Star Trek Klingon :) if you want to test for me just search for DigitalShop :)

    • @JasonPurkiss
      @JasonPurkiss ปีที่แล้ว

      worked very well

    • @jfversluis
      @jfversluis  ปีที่แล้ว +1

      Haha Klingon even! That's inclusiveness to the max!

  • @somerandominformation
    @somerandominformation 11 หลายเดือนก่อน

    Do you know how to translate an application dynamically by using Azure Translator or something? Because defining everything yourself in a separate file is not really scalable...

    • @jfversluis
      @jfversluis  11 หลายเดือนก่อน +1

      On windows use the Resxmanager plugin which has cloud powered translations. Doing it manually might not be great but it’s still the only way to be sure that your translations will be the best they can in each language. It just an intensive process unfortunately

  • @tanakamawere
    @tanakamawere ปีที่แล้ว

    Hie Gerald, unrelated to the video. It's a thought I recently had. I connected my app to the app centre and whenever the app crashed, it sent reports to Github. This was an Android .NET MAUI app. So the errors were in 'Android language' like "Java. something is null". How do I convert such platform specific errors to .NET MAUI specific errors?

    • @jfversluis
      @jfversluis  ปีที่แล้ว +1

      Depending on what it is exactly you can't really. Some stuff just happens on the underlaying layer. It will take some experience to start recognizing those errors.

  • @Lanthiren
    @Lanthiren ปีที่แล้ว

    Could you please do a media element video for an audio media player?

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      When MediaPlayer is released I will do a video on it again :)

  • @Alfred545
    @Alfred545 ปีที่แล้ว

    My visual studio doesn't recognize using ProjectName.Resources.Something, but i followed all you steps.Should i have some class in Resources folder?

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      Make sure that you have set the access modifier to public

    • @stevehutch
      @stevehutch ปีที่แล้ว

      @@jfversluis Hi Gerald, I am having this problem too, Visual Studio for Mac does not show the graphical editor, and also the ProjectName.Resources.Languages is not recognised and gives compilation error every time? The ViewModel, Model, Views folder are all recognised, but for some strange reason I cannot reference the Resources folder from a XAML page. I have set the build properties of the Resource.resx file as follows : Build action "embedded resource" copy to output directory : "do not copy", Custom Tool : PublicResXFileCodeGenerator, Custom To Namespace (left empty).

  • @dsantasot
    @dsantasot 7 หลายเดือนก่อน

    How this can be done using the new .NET MAUI extension in VS Code? 🤔

    • @jfversluis
      @jfversluis  7 หลายเดือนก่อน +1

      You can’t unless there is an extension for it. Else you’ll have to do it manually

  • @thomasgalliker
    @thomasgalliker 4 หลายเดือนก่อน

    Great tutorial. Sadly, Multilingual App Toolkit is not (yet) supported on .NET MAUI. Is there any progress?

    • @jfversluis
      @jfversluis  4 หลายเดือนก่อน

      I don't think so unfortunately!

    • @thomasgalliker
      @thomasgalliker 4 หลายเดือนก่อน

      You can temporarily enable a separate library with Multilingual App Toolkit, e.g. a netstandard2.0 class library. Later, when MAT supports MAUI projects, we can move the translations back to the MAUI project.Just as proposed here: github.com/microsoft/Multilingual-App-Toolkit/issues/10
      @@jfversluis

  • @giovanninovati7301
    @giovanninovati7301 ปีที่แล้ว +1

    Thanks, that works fine on Android, but in IOS it doesn't work at all! What's happening? What can we do?

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      Without any details that will be hard to say!

    • @giovanninovati7301
      @giovanninovati7301 ปีที่แล้ว

      @@jfversluis I created a new project and followed your tutorial step by step. I did exactly what you did. It compiles on both platforms. On android it works as expected, but on IOS the language does not change, even after i restart the app. Should i add a link to the project?

  • @alibourkaib3003
    @alibourkaib3003 ปีที่แล้ว +1

    Sir how to add change Language in
    new Shellcontent....
    {
    Title=AppResource.....(here)
    }

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      I’m sorry, not sure what you mean

    • @alibourkaib3003
      @alibourkaib3003 ปีที่แล้ว

      I want to change language in shell in cs

    • @yasminaamroun8682
      @yasminaamroun8682 ปีที่แล้ว

      @ALI BOURKAIB did it work with you in the Shel?

  • @KyleBeckman43
    @KyleBeckman43 ปีที่แล้ว

    I really like this approach, but the only downside I can see is the lack of intellicense as you're typing in the name of the resource to ensure proper spelling. Any idea if there's a way to get the list of options to show up as you're typing your XAML?

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      It depends on which method you're using. The first method definitely should show IntelliSense although it wasn't working in the video. The method with the extensions will indeed not have IntelliSense support unfortunately.

  • @jamg.barett749
    @jamg.barett749 ปีที่แล้ว

    Please make a video of google adsense on maui.

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      It’s on my todo list!

  • @OscarRodriguezArdila
    @OscarRodriguezArdila ปีที่แล้ว

    Hi does this work on IOS?

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      Definitely should, yes

    • @OscarRodriguezArdila
      @OscarRodriguezArdila ปีที่แล้ว +1

      @@jfversluis I tried and it doesn't change the language when clicking the button in your project. Could it be something with permissions of the app?

    • @giovanninovati7301
      @giovanninovati7301 ปีที่แล้ว +1

      I have the same problem. Did you find out a solution?

  • @krishnalekkala6506
    @krishnalekkala6506 ปีที่แล้ว +1

    th-cam.com/video/YHEdPg1vUr0/w-d-xo.html
    Hi, thank you so much for the video. Please note that this solution for me seems to be problematic if you compile in release mode. It seems to fail and you only see Microsoft.Maui.Controls.Binding for all the strings. (for me, only in release mode). Do you have guidance on that?
    Hi @gerald any idea on this issue ?

    • @luigyavila7985
      @luigyavila7985 ปีที่แล้ว +1

      It's true in release mode it doesn't work, did you find any solution for this?

  • @ihassantariq
    @ihassantariq 3 หลายเดือนก่อน

    @Gerald is RTL is supported like arabic lanaguage in .NET MAUI everywhere I have searched and found that there are still bugs. Thanks

  • @osamaiqbal6702
    @osamaiqbal6702 ปีที่แล้ว

    public object this[string resourceKey] => AppResources.ResourceManager.GetObject(resourceKey, AppResources.Culture) ?? Array.Empty();
    this is not working when i tried it from .xaml file
    Any Solution??