diff --git a/EnvelopeGenerator.Common/EnvelopeGenerator.Common.vbproj b/EnvelopeGenerator.Common/EnvelopeGenerator.Common.vbproj index d0d1b92e..98c3cf12 100644 --- a/EnvelopeGenerator.Common/EnvelopeGenerator.Common.vbproj +++ b/EnvelopeGenerator.Common/EnvelopeGenerator.Common.vbproj @@ -214,12 +214,15 @@ Model.en.resx True True + Always True True Model.resx + Always + @@ -256,11 +259,13 @@ PublicResXFileCodeGenerator Model.en.Designer.vb My.Resources + Always My.Resources PublicResXFileCodeGenerator Model.Designer.vb + Always diff --git a/EnvelopeGenerator.Common/Strings/Model.vb b/EnvelopeGenerator.Common/Strings/Model.vb new file mode 100644 index 00000000..283db720 --- /dev/null +++ b/EnvelopeGenerator.Common/Strings/Model.vb @@ -0,0 +1,3 @@ +Public Class Model + +End Class diff --git a/EnvelopeGenerator.Domain/Entities/Envelope.cs b/EnvelopeGenerator.Domain/Entities/Envelope.cs index ba6b1310..1d7120e3 100644 --- a/EnvelopeGenerator.Domain/Entities/Envelope.cs +++ b/EnvelopeGenerator.Domain/Entities/Envelope.cs @@ -100,19 +100,6 @@ namespace EnvelopeGenerator.Domain.Entities [NotMapped] public bool IsAlreadySent => Status > (int) Constants.EnvelopeStatus.EnvelopeSaved; - [NotMapped] - public string? StatusTranslated => Model.ResourceManager.GetString(Status.ToString()); - - [NotMapped] - public string? ContractTypeTranslated - { - get - { - string? oContractType = ContractType.ToString(); - return oContractType is null ? default : Model.ResourceManager.GetString(oContractType); - } - } - public IEnumerable? Documents { get; set; } public IEnumerable? History { get; set; } diff --git a/EnvelopeGenerator.Form/EnvelopeGenerator.Form.vbproj b/EnvelopeGenerator.Form/EnvelopeGenerator.Form.vbproj index dca6d5fa..e1aa1f0b 100644 --- a/EnvelopeGenerator.Form/EnvelopeGenerator.Form.vbproj +++ b/EnvelopeGenerator.Form/EnvelopeGenerator.Form.vbproj @@ -179,6 +179,7 @@ frmEnvelopeEditor.vb + Designer frmEnvelopeMainData.vb diff --git a/EnvelopeGenerator.GeneratorAPI/Controllers/LocalizationController.cs b/EnvelopeGenerator.GeneratorAPI/Controllers/LocalizationController.cs index c0fd54c1..2636d67c 100644 --- a/EnvelopeGenerator.GeneratorAPI/Controllers/LocalizationController.cs +++ b/EnvelopeGenerator.GeneratorAPI/Controllers/LocalizationController.cs @@ -1,5 +1,6 @@ using DigitalData.Core.API; using EnvelopeGenerator.Application.Resources; +using EnvelopeGenerator.Common; using Microsoft.AspNetCore.Localization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Caching.Memory; @@ -14,17 +15,24 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers private static readonly Guid L_KEY = Guid.NewGuid(); private readonly ILogger _logger; + private readonly IStringLocalizer _mLocalizer; private readonly IStringLocalizer _localizer; private readonly IMemoryCache _cache; - public LocalizationController(ILogger logger, IStringLocalizer localizer, IMemoryCache memoryCache) + + public LocalizationController( + ILogger logger, + IStringLocalizer localizer, + IMemoryCache memoryCache, + IStringLocalizer _modelLocalizer) { _logger = logger; _localizer = localizer; _cache = memoryCache; + _mLocalizer = _modelLocalizer; } [HttpGet] - public IActionResult GetAll() => Ok(_cache.GetOrCreate(L_KEY, _ => _localizer.ToDictionary())); + public IActionResult GetAll() => Ok(_cache.GetOrCreate(Language ?? string.Empty + L_KEY, _ => _mLocalizer.ToDictionary())); [HttpGet("lang")] public IActionResult GetLanguage() => Language is null ? NotFound() : Ok(Language); diff --git a/EnvelopeGenerator.GeneratorAPI/EnvelopeGenerator.GeneratorAPI.csproj b/EnvelopeGenerator.GeneratorAPI/EnvelopeGenerator.GeneratorAPI.csproj index e864cdc2..d306e9d7 100644 --- a/EnvelopeGenerator.GeneratorAPI/EnvelopeGenerator.GeneratorAPI.csproj +++ b/EnvelopeGenerator.GeneratorAPI/EnvelopeGenerator.GeneratorAPI.csproj @@ -25,6 +25,7 @@ + diff --git a/EnvelopeGenerator.GeneratorAPI/Program.cs b/EnvelopeGenerator.GeneratorAPI/Program.cs index ff15fba3..01b4c503 100644 --- a/EnvelopeGenerator.GeneratorAPI/Program.cs +++ b/EnvelopeGenerator.GeneratorAPI/Program.cs @@ -4,7 +4,9 @@ using DigitalData.UserManager.Application; using DigitalData.UserManager.Infrastructure.Repositories; using EnvelopeGenerator.Application; using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Localization; using Microsoft.EntityFrameworkCore; +using System.Globalization; var builder = WebApplication.CreateBuilder(args); @@ -73,7 +75,17 @@ if (app.Environment.IsDevelopment()) app.UseCors("AllowSpecificOriginsPolicy"); // Localizer -app.UseCookieBasedLocalizer("de-DE", "en-US"); +string[] supportedCultureNames = { "de-DE", "en-US" }; +IList list = supportedCultureNames.Select((string cn) => new CultureInfo(cn)).ToList(); +CultureInfo cultureInfo = list.FirstOrDefault() ?? throw new ArgumentNullException("supportedCultureNames", "Supported cultures cannot be empty."); +RequestLocalizationOptions requestLocalizationOptions = new RequestLocalizationOptions +{ + SupportedCultures = list, + SupportedUICultures = list +}; +requestLocalizationOptions.RequestCultureProviders.Add(new QueryStringRequestCultureProvider()); +app.UseRequestLocalization(requestLocalizationOptions); + app.UseHttpsRedirection();