aksoftware98 / multilanguages

AKSoftware.Localization.MultiLanguages is a package for .NET developers allows them to easily build apps target multiple languages with just few lines of code
MIT License
85 stars 15 forks source link

suggetion use #55

Open gheith3 opened 1 year ago

gheith3 commented 1 year ago

create blazor component AppTranslation.razor

@if (Values is null)
{
    @languageContainer.Keys[Key]
}
else
{
    @languageContainer.Keys[Key, Values]
}

@code {
    [Parameter]
    public required string Key { get; set; }

    [Parameter]
    public Object? Values { get; set; }

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

then in any where inside your project you can use it like

<AppTranslation Key="HomePage:Title" />

by this way all text will update immediately when you change lang