Blazor Webassembly Globalization in Blazor Numeric TextBox component

Hi guys, I'm watn to use 'es' (Spanish) culture on my Numeric TextBox on Blazor Webassembly, and I am following documentation but I am getting this error on de component when I add this line of code:

[Inject]
    protected IJSRuntime JsRuntime { get; set; }
    protected override async Task OnInitializedAsync()
    {
        this.JsRuntime.Sf().LoadLocaleData(await Http.GetJsonAsync<object>("blazor-locale/src/de.json")).SetCulture("es");
    }

'This set culture method is deprecated'


What is the new way of adding the culture to my Numeric TextBox ?


Thank you

11 Replies 1 reply marked as answer

SN Sevvandhi Nagulan Syncfusion Team May 11, 2021 12:45 PM UTC

Hi Luis, 


Greetings from Syncfusion support. 


We checked your query.  In the Spanish culture, we created a sample for globalization in the numeric textbox component, which we have attached below for your reference. Kindly refer the below sample. 




Please refer the below UG documentation for more information about globalization in web assembly. 




Meanwhile, we correct the UG documentation code in the numeric textbox globalization topic and refresh in the online soon. 


Kindly get back to us for further assistance. 


Regards, 
Sevvandhi N 


Marked as answer

LR Luis Roberto May 13, 2021 06:09 PM UTC

Thank you very much  for your help guys, I really appreciate it.

I am following the guide you provided me to implement the es culture - UG Link: https://blazor.syncfusion.com/documentation/common/localization/#enable-localization-in-blazor-webassembly-application 

I did all the steps, but when i run the program I get the following error 
blazor.webassembly.js:1 Microsoft.JSInterop.JSException: Could not find 'cultureInfo.get' ('cultureInfo' was undefined).

On Program.cs there is a line that call that 

var result = await jsInterop.InvokeAsync<string>("cultureInfo.get");

Obviously I'm doing something wrong because the example project you kindly provided works great.

Maybe you could guide me a bit with this error.

The only difference with the example project is that I am using the syncfusion blazor  version 19.1.0.63 and the example project is using version 19.1.0.59

Thank you very much


LR Luis Roberto May 13, 2021 10:19 PM UTC

Hi guys, I created a new clean solution and followed the steps on the guide and everything works great.

So I was doing something wrong, but it works now.

Thank you very much

Take care


SN Sevvandhi Nagulan Syncfusion Team May 14, 2021 05:32 AM UTC

Hi Luis, 



We are glad to hear that the reported issue has been resolved. Please get back to us if you need further assistance. 



Regards, 
Sevvandhi N 



LR Luis Roberto May 15, 2021 07:18 PM UTC

Hi, thank you for all your help, although I am using the Spanish culture correctly, I have a little problem, the thousands and decimal separators are different in Spain and Mexico, but there is no resouse es-MX.

So although I want to use es culture in my controls, on NumerictTextBox I need to use en-US which is similar to the one whe use in Mexico.

So I use the numerictextbox this way 

<SfNumericTextBox TValue="decimal" Locale="en-US"></SfNumericTextBox>

It shows the correct format for example 10.55  but the problem is I can't write . (point to separete decimals) I have to write , (semicolon) and then the crontrol shows the correct format, so If I want the control shows 10.55 I have to write 10,55

The same behavior occurs in the sample solution you that you kindly provided

Thanks




SN Sevvandhi Nagulan Syncfusion Team May 17, 2021 02:27 PM UTC

Hi Luis, 


Greetings from Syncfusion support. 


We checked your query. We are currently validating the reported requirement at our end. We will update further details on 19th of May,2021. We appreciate your patience until then. 


Regards, 
Sevvandhi N 



SN Sevvandhi Nagulan Syncfusion Team May 19, 2021 03:47 PM UTC

Hi Luis, 
 
 
Thanks for your patience. 
 
We checked your query of “Can’t type decimal separator dot in Spain culture(es-MX)”.  We can type decimal separator dot when globalizing the component to Spanish culture. In Spanish culture, the decimal separator is a dot (.) and the thousand separator is a comma (,).  Please refer the below link for more information about separators. 
 
 
 
Also, you can create the new resource file with the culture name provided in the program.cs for defining the culture definitions. Please refer the below screenshot. 
 
 
 
 
 
ublic static async Task Main(string[] args) 
        { 
            // Add your Syncfusion license key for Blazor platform with corresponding Syncfusion NuGet version referred in project. For more information about license key see https://help.syncfusion.com/common/essential-studio/licensing/license-key. 
            // Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Add your license key here");  
            var builder = WebAssemblyHostBuilder.CreateDefault(args); 
            builder.RootComponents.Add<App>("#app"); 
            builder.Services.AddSyncfusionBlazor(); 
            builder.Services.AddSingleton(typeof(ISyncfusionStringLocalizer), typeof(SyncfusionLocalizer)); 
 
            // Set the default culture of the application 
            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("es-MX"); 
            CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("es-MX"); 
 
                        // Get the modified culture from culture switcher 
                        var host = builder.Build(); 
                        var jsInterop = host.Services.GetRequiredService<IJSRuntime>(); 
                        var result = await jsInterop.InvokeAsync<string>("cultureInfo.get"); 
                        if (result != null) 
                        { 
                            // Set the culture from culture switcher 
                            var culture = new CultureInfo(result); 
                            CultureInfo.DefaultThreadCurrentCulture = culture; 
                            CultureInfo.DefaultThreadCurrentUICulture = culture; 
                        } 
 
            builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 
 
            await builder.Build().RunAsync(); 
        } 
 
 
 
So please provide the additional information about the issue or requirement such as video demonstration of the issue or modify the below sample to replicate the issue and provide issue replication steps along with that sample. It would be helpful to understand the issue at our end. 
 
 
 
 
 
Regards, 
Sevvandhi N 



LR Luis Roberto May 20, 2021 06:04 PM UTC

Thank very much guys, I am using the es-MX you provide on the sample project and it works great, I am gonna add spanish phrases to that file.

Thank you very muy for your help.

Take care


SN Sevvandhi Nagulan Syncfusion Team May 21, 2021 04:21 AM UTC

Hi Luis, 



We are glad to hear that the reported issue has been resolved. Please get back to us if you need further assistance. 



Regards, 
Sevvandhi N 



FM François Mouchati December 30, 2021 06:38 PM UTC

Hello,

I too have the Could not find 'cultureInfo.get' error.
I got ride of it when running blazor wasm as a stand aline by adding


<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>

 in my blazor csproj (running net6).

yet once the blazor wasm app is embedded into my aspnet core app the error is back.



BC Berly Christopher Syncfusion Team December 31, 2021 08:45 AM UTC

Hi François, 
  
If you are integrating the Blazor WASM application into ASP.NET Core application, we need to follow the below mentioned steps in the application end. Kindly ensure that the mentioned steps are added correctly in the application. 
  
  
  
Still issue persists, please share issue reproducing sample with us that will help us to check and proceed further from our end. 
  
Regards, 
Berly B.C 


Loader.
Up arrow icon