Erweiterung der DTOs und Implementierung der Lokalisierungsdienste

- Neue DTO-Extension-Methoden hinzugefügt, um die Verarbeitung und Zuweisung von Nachrichten und Benachrichtigungen in Ergebnisobjekten zu vereinfachen.
- Lokalisierungsunterstützung in der API-Schicht implementiert, einschließlich Cookie-basierter Lokalisierung und Konfiguration unterstützter Kulturen.
- Die Integration von StringLocalizer in die API-Schicht wurde durchgeführt, um eine nahtlose Mehrsprachigkeit zu ermöglichen.
- Fehlerbehandlung für fehlende Konfigurationseinstellungen verbessert.

Die Änderungen verbessern die Flexibilität und Wartbarkeit des Codes und unterstützen eine effizientere Internationalisierung der Anwendung.
This commit is contained in:
Developer 02
2024-04-30 17:01:26 +02:00
parent f6d8721c27
commit 4b71836fea
36 changed files with 303 additions and 1109 deletions

View File

@@ -1,4 +1,5 @@
using DigitalData.Core.Contracts.Application;
using DigitalData.Core.DTO;
using Microsoft.AspNetCore.Mvc;
using System.Text;
@@ -50,10 +51,8 @@ namespace DigitalData.Core.API
/// Returns an ObjectResult representing an internal server error (status code 500) with optional exception and message details.
/// </summary>
/// <param name="controllerBase">The ControllerBase instance representing the controller.</param>
/// <param name="ex">Optional. The exception that occurred, if any.</param>
/// <param name="message">Optional. A custom error message to include in the response.</param>
/// /// <param name="messageKey">Optional. A custom error message key to include in the response.</param>
/// <param name="result">Optional. A custom error resul to include in the response.</param>
/// <returns>An ObjectResult representing an internal server error (status code 500).</returns>
public static ObjectResult InnerServiceError(this ControllerBase controllerBase, IServiceMessage? serviceMessage = null) => controllerBase.StatusCode(500, serviceMessage);
public static ObjectResult InnerServiceError(this ControllerBase controllerBase, Result? result = null) => controllerBase.StatusCode(500, result);
}
}

View File

@@ -13,6 +13,7 @@
<ItemGroup>
<ProjectReference Include="..\DigitalData.Core.Contracts\DigitalData.Core.Contracts.csproj" />
<ProjectReference Include="..\DigitalData.Core.DTO\DigitalData.Core.DTO.csproj" />
</ItemGroup>
</Project>

View File

@@ -20,10 +20,10 @@ namespace DigitalData.Core.API
public static IServiceCollection AddCookieBasedLocalizer(this IServiceCollection services, string resourcesPath)
{
// Adds localization services with the specified resources path.
services.AddLocalization(options => options.ResourcesPath = resourcesPath);
services.AddLocalization(options => options.ResourcesPath = resourcesPath)
// Adds MVC services with view localization and data annotations localization.
services.AddMvc().AddViewLocalization(Microsoft.AspNetCore.Mvc.Razor.LanguageViewLocationExpanderFormat.Suffix)
.AddMvc().AddViewLocalization(Microsoft.AspNetCore.Mvc.Razor.LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization();
return services;