Toolbelt.Blazor.I18nText
Toolbelt.Blazor.I18nText copied to clipboard
Synchronous version of GetTextTableAsync .
I want to have a base component and store all the table data there in a property , so in other component I just inherit from base component and variable will be available to use on other derived component.
so when using .Result in property it hangs the UI.
public class MyTextBaseComponent : ComponentBase
{
[Inject] Toolbelt.Blazor.I18nText.I18nText I18nText { get; set; }
public I18nText.MyText _MyText { get; set; } = null;
public I18nText.Dairy MyText
{
get
{
if (_MyText == null)
{
_MyText = I18nText.GetTextTableAsync<I18nText.MyText>(this).Result;
}
return _MyText;
}
}
}
in .razor file.
@page "/"
@inherits MyTextBaseComponent
<span>
@MyText.Farmer
</span>
Sorry to late reply!
I'm not sure to make a synchronous version of "GetTextTableAsync" is possible.
Because, "Blazor i18n Text" on Blazor WebAssembly app currently depends on fetching localized text resource JSON file via HTTP request from client to server, and synchronous HTTP requests on the main thread have been deprecated on modern web browsers.
See also: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Synchronous_and_Asynchronous_Requests#Synchronous_request
To be available to make a synchronous version of "GetTextTableAsync", we have to innovate something new mechanism to break through that limitation.
By the way, what is the reason that you don't implement "OnInitializedAsync" in the base component?
By the way, what is the reason that you don't implement "OnInitializedAsync" in the base component?
I tried it before , I was getting some error but looks like now it is working perfectly fine.
Thank you :) !
so may be we can close this issue.