CultureInfo zur Culture hinzugefügt und die Benutzeroberfläche aktualisiert, um den NativeName für eine verbesserte Lokalisierung anzuzeigen.

This commit is contained in:
Developer 02 2024-05-28 16:19:01 +02:00
parent 9fa5827b09
commit 3b27260b14
9 changed files with 38 additions and 16 deletions

View File

@ -145,6 +145,6 @@
<value>Ein unerwarteter Fehler ist aufgetreten.</value> <value>Ein unerwarteter Fehler ist aufgetreten.</value>
</data> </data>
<data name="WrongAccessCode" xml:space="preserve"> <data name="WrongAccessCode" xml:space="preserve">
<value>Ungültiger Zugangscode.</value> <value>Dokument unterschreiben</value>
</data> </data>
</root> </root>

View File

@ -141,6 +141,9 @@
<data name="LockedTitle" xml:space="preserve"> <data name="LockedTitle" xml:space="preserve">
<value>Document requires an access code</value> <value>Document requires an access code</value>
</data> </data>
<data name="String1" xml:space="preserve">
<value>Dokument unterschreiben</value>
</data>
<data name="UnexpectedError" xml:space="preserve"> <data name="UnexpectedError" xml:space="preserve">
<value>An unexpected error has occurred.</value> <value>An unexpected error has occurred.</value>
</data> </data>

View File

@ -1,4 +1,5 @@
using AngleSharp.Common; using AngleSharp.Common;
using DigitalData.Core.API;
using EnvelopeGenerator.Application.Resources; using EnvelopeGenerator.Application.Resources;
using EnvelopeGenerator.Web.Models; using EnvelopeGenerator.Web.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -23,9 +24,15 @@ namespace EnvelopeGenerator.Web.Controllers.Test
public IActionResult Localize([FromQuery] string key = "de_DE") => Ok(_localizer[key]); public IActionResult Localize([FromQuery] string key = "de_DE") => Ok(_localizer[key]);
[HttpGet("fi-class")] [HttpGet("fi-class")]
public IActionResult GetFIClass(string? lang = null) => lang is null ? Ok(_cultures.FIClasses) : Ok(_cultures.FIClassOf(lang)); public IActionResult GetFIClass(string? lang = null) => lang is null ? Ok(_cultures.FIClasses) : Ok(_cultures[lang]?.FIClass);
[HttpGet("culture")] [HttpGet("culture")]
public IActionResult GetCultures(string? lang = null) => lang is null ? Ok(_cultures) : Ok(_cultures.CultureOf(lang)); public IActionResult GetCultures(string? lang = null) => lang is null ? Ok(_cultures) : Ok(_cultures[lang]);
[HttpGet("to-culture-info")]
public IActionResult ToCultureInfo(string locale) => Ok(locale.ToCultureInfo());
[HttpGet("two-letter-iso-language-name")]
public IActionResult TwoLetterISOLanguageName(string locale) => Ok(locale.TwoLetterISOLanguageName());
} }
} }

View File

@ -1,8 +1,18 @@
namespace EnvelopeGenerator.Web.Models using System.Globalization;
namespace EnvelopeGenerator.Web.Models
{ {
public class Culture public class Culture
{ {
public string Language { get; init; } = string.Empty; private string _language = string.Empty;
public string Language { get => _language;
init {
_language = value;
Info = new(value);
}
}
public string FIClass { get; init; } = string.Empty; public string FIClass { get; init; } = string.Empty;
public CultureInfo? Info { get; init; }
} }
} }

View File

@ -6,10 +6,8 @@
public IEnumerable<string> FIClasses => this.Select(c => c.FIClass); public IEnumerable<string> FIClasses => this.Select(c => c.FIClass);
public Culture? CultureOf(string? language) => language is null ? null : this.Where(c => c.Language == language).FirstOrDefault();
public Culture Default => this.First(); public Culture Default => this.First();
public string FIClassOf(string? language) => language is null ? string.Empty : CultureOf(language)?.FIClass ?? string.Empty; public Culture? this[string? language] => language is null ? null : this.Where(c => c.Language == language).FirstOrDefault();
} }
} }

View File

@ -39,14 +39,16 @@
<div class="col-4 mb-3 d-flex justify-content-center align-items-center"> <div class="col-4 mb-3 d-flex justify-content-center align-items-center">
<div class="dropdown"> <div class="dropdown">
<button class="btn btn-outline-secondary dropdown-toggle" type="button" id="langDropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false"> <button class="btn btn-outline-secondary dropdown-toggle" type="button" id="langDropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false">
<span class="fi @_cultures.FIClassOf(userLanguage).TrySanitize(_sanitizer) me-2" id="selectedFlag"></span><span id="selectedLanguage"></span> <span class="fi @_cultures[userLanguage]?.FIClass.TrySanitize(_sanitizer) me-2" id="selectedFlag"></span><span id="selectedLanguage"></span>
</button> </button>
<ul class="dropdown-menu" aria-labelledby="langDropdownMenuButton"> <ul class="dropdown-menu" aria-labelledby="langDropdownMenuButton">
@foreach(var lang in _cultures.Languages) @foreach(var culture in _cultures)
{ {
var lang = culture.Language;
var info = culture.Info;
<li> <li>
<a class="dropdown-item" data-language="@lang.TrySanitize(_sanitizer)" data-flag="@_cultures.FIClassOf(lang).TrySanitize(_sanitizer)"> <a class="dropdown-item" data-language="@lang.TrySanitize(_sanitizer)" data-flag="@_cultures[lang]?.FIClass.TrySanitize(_sanitizer)">
<span class="fi @_cultures.FIClassOf(lang).TrySanitize(_sanitizer) me-2"></span>@_localizer[lang].Value.TrySanitize(_sanitizer) <span class="fi @_cultures[lang]?.FIClass.TrySanitize(_sanitizer) me-2"></span>@info?.Parent.NativeName
</a> </a>
</li> </li>
} }

View File

@ -16,7 +16,7 @@
}, },
"AdminPassword": "dd", "AdminPassword": "dd",
"PSPDFKitLicenseKey_SignFlow": "y8VgCpBgUfNlpKJZC-GwjpPs-S-KFBHv4RywfHbqpBAbO0XxRuWDaMGZtIaMrXBDlndlJLk---Ve93xjI_ZR4sbFymf4Ot97yTYUMeDdL2LYXhspkEnSAtkXf9zqepNL1v_0DMibjpqXFQMkVB1y3D5xdnOg-iJuCCZEMhZ780qg04_H_nmx63uSgxjN0GJxC8YvsbnRcUZ2l_idImMvWL0HMqB5B7oEpNenasA0RK0uapFRTa7NIQok0phpTHZYKB4qvj7od2yxlytGB7qBl4-lwT70DSQ9mrLkCWbuzZ9cV9D8fDzdFXr6WoZdOYpkrUadRbsy2bhPq_ukxszDWN4JGhebo0XKUK_YfgvSlS7lFOxHNblHeC9B7gZ8T-VuQ_z1QA2JYRf1dmhSuclnW00diShIg-N0I79PWGsQE4j40XtVpyWcN9uT9hMuiRpL0LzHV4YgsgBrgKgs_moqL7f0L4-MwaS25Dx4Wcz4ttKaerLavwMM4CJHI3DNqTC5UUEG6EViFxBQtrmuAS7kiw2nWjvXO7kUA24NARtsRCphjWE4l6wSMdh7kpqhfbV7_hdb5xXYGALNPkv8En6zPpFIew8DDcOH9dgxfKMI34LLhkEWqovZW_7fXNJTEIHVpR0DSPbZrmyEwkECnbDcNzjyFk2M1fzstJj_dSotyZvS57XJK2DgojbRgXL9pncs", "PSPDFKitLicenseKey_SignFlow": "y8VgCpBgUfNlpKJZC-GwjpPs-S-KFBHv4RywfHbqpBAbO0XxRuWDaMGZtIaMrXBDlndlJLk---Ve93xjI_ZR4sbFymf4Ot97yTYUMeDdL2LYXhspkEnSAtkXf9zqepNL1v_0DMibjpqXFQMkVB1y3D5xdnOg-iJuCCZEMhZ780qg04_H_nmx63uSgxjN0GJxC8YvsbnRcUZ2l_idImMvWL0HMqB5B7oEpNenasA0RK0uapFRTa7NIQok0phpTHZYKB4qvj7od2yxlytGB7qBl4-lwT70DSQ9mrLkCWbuzZ9cV9D8fDzdFXr6WoZdOYpkrUadRbsy2bhPq_ukxszDWN4JGhebo0XKUK_YfgvSlS7lFOxHNblHeC9B7gZ8T-VuQ_z1QA2JYRf1dmhSuclnW00diShIg-N0I79PWGsQE4j40XtVpyWcN9uT9hMuiRpL0LzHV4YgsgBrgKgs_moqL7f0L4-MwaS25Dx4Wcz4ttKaerLavwMM4CJHI3DNqTC5UUEG6EViFxBQtrmuAS7kiw2nWjvXO7kUA24NARtsRCphjWE4l6wSMdh7kpqhfbV7_hdb5xXYGALNPkv8En6zPpFIew8DDcOH9dgxfKMI34LLhkEWqovZW_7fXNJTEIHVpR0DSPbZrmyEwkECnbDcNzjyFk2M1fzstJj_dSotyZvS57XJK2DgojbRgXL9pncs",
"UseCSPInDev": true, "UseCSPInDev": false,
"Content-Security-Policy": [ // The first format parameter {0} will be replaced by the nonce value. "Content-Security-Policy": [ // The first format parameter {0} will be replaced by the nonce value.
"default-src 'self'", "default-src 'self'",
"script-src 'self' 'nonce-{0}' 'unsafe-inline' 'unsafe-eval' blob: data:", "script-src 'self' 'nonce-{0}' 'unsafe-inline' 'unsafe-eval' blob: data:",

View File

@ -10,7 +10,7 @@ const ActionType = {
} }
class App { class App {
constructor(envelopeKey, envelopeReceiver, documentBytes, licenseKey, container) { constructor(envelopeKey, envelopeReceiver, documentBytes, licenseKey, locale, container) {
this.container = container ?? `#${this.constructor.name.toLowerCase()}`; this.container = container ?? `#${this.constructor.name.toLowerCase()}`;
this.envelopeKey = envelopeKey this.envelopeKey = envelopeKey
@ -25,6 +25,7 @@ class App {
this.envelopeReceiver = envelopeReceiver; this.envelopeReceiver = envelopeReceiver;
this.documentBytes = documentBytes; this.documentBytes = documentBytes;
this.licenseKey = licenseKey; this.licenseKey = licenseKey;
this.locale = locale;
} }
// This function will be called from the ShowEnvelope.razor page // This function will be called from the ShowEnvelope.razor page

View File

@ -14,8 +14,9 @@
// Load the PSPDFKit UI by setting a target element as the container to render in // Load the PSPDFKit UI by setting a target element as the container to render in
// and a arraybuffer which represents the document that should be displayed. // and a arraybuffer which represents the document that should be displayed.
loadPSPDFKit(arrayBuffer, container, licenseKey) { loadPSPDFKit(arrayBuffer, container, licenseKey, locale) {
return PSPDFKit.load({ return PSPDFKit.load({
locale: locale,
licenseKey: licenseKey, licenseKey: licenseKey,
styleSheets: ['/css/site.css'], styleSheets: ['/css/site.css'],
container: container, container: container,