Closed SoumyadipYT-OSS closed 4 months ago
Hello @SoumyadipYT-OSS ... We don't have the ability to troubleshoot developer apps given our staffing and workload. See if you can determine what's wrong with your app by following the guidance in the globalization and localization articles, which start here ...
https://learn.microsoft.com/aspnet/core/fundamentals/localization
If you need general support, we recommend public community support forums ....
If you think you've found a problem with one of our articles, you can open an issue using the Open a documentation issue link/feedback form at the bottom of the article. Use of the form adds metadata to your GitHub issue that cross-links the topic and pings the author automatically for a faster response.
Description
I am working in Razor pages: So in the program.cs file it looks like this:
using Microsoft.AspNetCore.Localization; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using RazorPagesMovie.Data; using System.Globalization; var builder = WebApplication.CreateBuilder(args);
// Add services to the container. builder.Services.AddRazorPages(); builder.Services.AddDbContext(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("RazorPagesMovieContext") ?? throw new InvalidOperationException("Connection string 'RazorPagesMovieContext' not found.")));
var app = builder.Build();
// Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); }
var defaultCulture = new CultureInfo("es-UY"); var indianCulture = new CultureInfo("hi-IN"); // Hindi (India)
var localizationOptions = new RequestLocalizationOptions { DefaultRequestCulture = new RequestCulture(defaultCulture), SupportedCultures = new List { defaultCulture, indianCulture },
SupportedUICultures = new List { defaultCulture, indianCulture }
};
app.UseRequestLocalization(localizationOptions);
app.UseHttpsRedirection(); app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.Run();
In the Index.cshtml I've added:
@page @System.Globalization.CultureInfo.CurrentCulture // added line
@model IndexModel @{ ViewData["Title"] = "Home page"; }
Welcome
Learn about building Web apps with ASP.NET Core.
Output is okay. Showing (en-IN) that means english-India. But the price tag value, it still doesn't support comma[","] sign to take input. I have also downloaded the globalization and jQuery NuGet packages and applied it.
Page URL
https://jqueryvalidation.org/
Content source URL
https://github.com/dotnet/AspNetCore.Docs/issues/4076#issuecomment-326590420
Document ID
No document ID
Article author
Soumyadip Majumder