Default localization to "de-DE" and refactor resources
Added a new `Model` class in the `EnvelopeGenerator.Domain.Resources` namespace as a marker for `IStringLocalizer` resource lookup. Updated `EnvelopeSenderPage.razor` to use the new `Model` class for localization. Modified `LocalizationController` to default to "de-DE" when no culture is specified or found. Refactored localization setup in `Program.cs` to use a fixed default culture of "de-DE" and persist culture via cookies. Removed dynamic culture setup and `QueryStringRequestCultureProvider`. Performed minor cleanup in `LocalizationController` and `Program.cs` to align with the new localization approach.
This commit is contained in:
@@ -410,16 +410,16 @@ try
|
||||
// Set CORS policy
|
||||
app.UseCors("AllowSpecificOriginsPolicy");
|
||||
|
||||
// Localization
|
||||
string[] supportedCultureNames = ["de-DE", "en-US"];
|
||||
IList<CultureInfo> list = [.. supportedCultureNames.Select(cn => new CultureInfo(cn))];
|
||||
var cultureInfo = list.FirstOrDefault() ?? throw new InvalidOperationException("There is no supported culture.");
|
||||
// Localization (fixed to German for now; persisted via cookie)
|
||||
var defaultCulture = new CultureInfo("de-DE");
|
||||
IList<CultureInfo> list = [defaultCulture];
|
||||
var requestLocalizationOptions = new RequestLocalizationOptions
|
||||
{
|
||||
DefaultRequestCulture = new RequestCulture(defaultCulture),
|
||||
SupportedCultures = list,
|
||||
SupportedUICultures = list
|
||||
SupportedUICultures = list,
|
||||
RequestCultureProviders = [new CookieRequestCultureProvider()]
|
||||
};
|
||||
requestLocalizationOptions.RequestCultureProviders.Add(new QueryStringRequestCultureProvider());
|
||||
app.UseRequestLocalization(requestLocalizationOptions);
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
Reference in New Issue
Block a user