Localization In .NET MAUI (Multi Language Support)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome to my channel in this video I am going to show you demo about implementing localization in.net Navi so here I just created new project let me add here one folder in resources folder okay now in this folder I am just going to add one resource file okay now here in this file you can just provide data in a key value format so here in name I'm just going to add Title One and here's some great king message now let me access this file here on main page so for that here I am just going to add namespace of stream folder okay now from this folder I am just going to access this resource file and from there that title I'm just going to display the title value okay now when I run the application it's just going to display whatever the value available here okay it's displaying here now let's say you want to support multiple languages for one app so for that you need to add multiple resource file so let me add another resource file here I'm just going to add a resource file for Hindi language okay here after file name you need to just provide a country language code so let me add here Hindi language code okay now I'm just going to add here key as a title one and here in a value I'm just going to add some creating message in in the language okay now if I run this application then it is going to display greeting here in English language format because by default it's just accessing this resources file now to display in this Hindi language here in a app.jaml.cs I'm just going to set cultural okay so here in our culture info I'm just going to provide language code okay now let me run the application now it's just going to display text from this Hindi language resource file okay so here it display now let me add another resource file also for another language so here in a stream folder I'm just going to add new resource file and some country code here so I'm just going to add industry language okay now here I'm just going to change this country language code to Russian language now if I run the application then it is going to display grating message in the same language okay now let's add code related to switching language dynamically so for that let me add here one extension folder in that I'm just going to add one class that is going to inherit markup extension interface okay so here in a key I'm just going to pass like what are the key available here in a resources file that key I'm just going to pass here in a translate extension and here I will just add some binding information so before that let me add here another class that's just going to translate the language foreign so using this instance I'm just going to set culture information okay so using this translator dot instant dot culture info I'm just going to assign a culture in value dynamically now let me add here indexer so based on culture info and the key that I'm just going to pass from here it's just going to you can be text so here I'm just going to pass e now based on key I'm just going to return tags so from the app resources I'm just going to patch value based on P and the culture into that set here okay now let's add binding information here in translate extension I'm just going to create binding and here I'm just going to pass translator dot instance as a source and here in a part in an added format I am just going to pass the p okay so whatever the t i defined in UI that P is binding object going to contain now this binding information I'm just going to return from here okay now let's look this translate extension here on main page over here I'm just going to add namespace of extension folder okay now here instead of this code I am just going to use now extension call and translate and here I'm just going to pass title one okay now let me set translation information like a translation language here on app.gml.cso now here I can use translator that instance the culture info is equal to what is the culture input I want to set okay now let me run the application so see like this title one is binding using this translator or not okay so it's displaying in a Hindi language now let me add here multiple radio button and based on selection I'm just going to switch the language dynamically okay so here in vertical State layout I'm just going to add radio button okay so here like whenever I change any country so that language it's going to reflect here so now let me add check change event for all the radio button so here now I'm just going to create check change event for all video button okay now here input behind I'm just going to set based on whatever the radio button involved involved that translation information I'm just going to use so here let me just copy this so this is going to set for when the India radio button involved then this culture is going to start and here let me just use Russian language culture info and by default here I'm just going to pass now so we're just going to use that default app resource okay now let me run the application okay so by default it displaying this Hindi languages because here we set this default cultural information days now if I select any of radio button it's not changing because here in a translator I need to inherit I notified property change and let me add here one matter so with the culture information like when I said culture information that time I'm just going to involve this on property change matter also okay now here I will call translator dot instant dot property change on property change method I will call this method so it is going to change it switch the language dynamically now let me run the application okay so here on the click of radio button it's just switching the language okay so that's all for today I hope you like this video and thank you so much for watching it
Info
Channel: Programming With Pragnesh
Views: 1,483
Rating: undefined out of 5
Keywords: Localization in .NET MAUI, Multi Lanaguage Support In .NET MAUI, Laguage in .NET MAUI, .net maui, net maui, maui c#, maui tutorial, maui .net, maui, C# maui, dotnet maui tutorial, blazor tutorial, blazor crud, .net maui app
Id: YHEdPg1vUr0
Channel Id: undefined
Length: 13min 14sec (794 seconds)
Published: Wed Apr 19 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.