aksoftware98/multilanguages

After Change Language not Change Language Menu

Closed this issue · 5 comments

Hi AK , can you show me how refresh NavMenu Language after change Language ?
Thanks
Walter

Hi!
By default, Blazor rerenders the changed component and it's children only, so after you change the language just navigate to any other component and then it will be refreshed.
But I will check that issue to let everything refresh at once.
Thank you

Hi Ahmad
Thanks for your answer
the component is very intresting but need to improve , becouse i have put two flag in the top of page in MainLayout and when i click and change page as you suggest it change only item menu of change page

@inherits LayoutComponentBase
@Inject ILanguageContainerService languageContainer
@Inject NavigationManager navigationManager

<div class="content px-4">
    @Body
</div>

@code
{
void SetLanguage(string language)
{
languageContainer.SetLanguage(System.Globalization.CultureInfo.GetCultureInfo(language));
navigationManager.NavigateTo("/counter");

}

}

Okay, noted I will try to fix that in the next version after few days.

Thank you

Thanks Ahmad
please read the other request by me for store language
Thanks a lot

Sorry for being that

This issue has been solved at the latest version of the code
The new package has just been released
You can install it from here:

Install-Package AKSoftware.MultiLanguages.Localization.Blazor

Now to be able to update the all components all you have to do is to add the following namespace in the _imports.razor file

using AKSoftware.MultiLanguages.Localization.Blazor

And within each localized component you need to call the OnInitialized method or OnInitializedAsync and add the following line

 protected override void OnInitialized()
    {
        languageContainer.InitLocalizedComponent(this);
    }

That's everything now whenever you change the language all the registered components will be updated automatically, and regarding storing the language a new sample has been published you can find it in the following link which contains a full usage of all the new features based on .NET 5.0
https://github.com/aksoftware98/multilanguages/tree/master/src/BlazorAKLocalization

I will close this issue for now, and if you figure out anything feel free to open a new one
Thanks again for your interest