Skip to content

Additional example for SupportedCultures to support ALL cultures #36232

@ThinkElevenDave

Description

@ThinkElevenDave

Description

[Enter feedback here]
The docs provide an example of supporting two cultures, but many people (based on StackOverflow activity) simply want numeric/date support dynamically without having to specify EVERY culture (of which they might not even know the end user's culture).

Frustratingly, our premium Copilot license in VS continues to suggest that, "options.SupportedCultures = null; // support all cultures" which appears to be both incorrect and misleading.

Therefore the documentation should also document how to dynamically support every culture, e.g.:

app.UseRequestLocalization(options =>
{
	var supportedCultures = CultureInfo.GetCultures(CultureTypes.AllCultures)
										.Where(cul => !string.IsNullOrEmpty(cul.Name))
										.ToArray();

	options.DefaultRequestCulture = new RequestCulture("en-GB"); // suggest using your largest audience's culture here
	options.SupportedCultures = supportedCultures;
	options.SupportedUICultures = supportedCultures;
});

Page URL

https://learn.microsoft.com/en-us/aspnet/core/blazor/globalization-localization?view=aspnetcore-8.0#dynamically-set-the-culture-in-a-blazor-web-app-by-user-preference

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/globalization-localization.md

Document ID

d6f07538-228e-9f96-680f-6c324caf11d6

Platform Id

bd2a8fe1-da71-2bfb-045d-1b5f49d944a4

Article author

@guardrex

Metadata

  • ID: 15e7c51d-1839-1849-813a-23c4d21c64ae
  • PlatformId: bd2a8fe1-da71-2bfb-045d-1b5f49d944a4
  • Service: aspnet-core
  • Sub-service: blazor

Related Issues

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions