Added localized strings for the cookie consent modal in de-DE, en-US, and fr-FR resource files. Updated _CookieConsentPartial.cshtml to use these resources for the modal title, message, and accept button, enabling multilingual support. Injected IStringLocalizer to support string localization in the view.
42 lines
1.7 KiB
Plaintext
42 lines
1.7 KiB
Plaintext
@using Microsoft.AspNetCore.Http.Features
|
|
@inject IStringLocalizer<SharedResource> _localizer
|
|
|
|
@{
|
|
var nonce = _accessor.HttpContext?.Items["csp-nonce"] as string;
|
|
var consentFeature = Context.Features.Get<ITrackingConsentFeature>();
|
|
var showBanner = !consentFeature?.CanTrack ?? false;
|
|
var cookieString = consentFeature?.CreateConsentCookie();
|
|
}
|
|
|
|
@if (showBanner)
|
|
{
|
|
<div class="modal fade" id="cookieConsent" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h1 class="modal-title fs-5" id="staticBackdropLabel">@_localizer["PrivacyNotice"]</h1>
|
|
</div>
|
|
<div class="modal-body">
|
|
@_localizer["CookieConsentMessage"]
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary accept-policy close" data-bs-dismiss="modal" data-cookie-string="@cookieString"><span aria-hidden="true">@_localizer["Accept"]</span></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script nonce="@nonce">
|
|
window.onload = function () {
|
|
var modal = new bootstrap.Modal(document.getElementById('cookieConsent'));
|
|
modal.show();
|
|
};
|
|
|
|
(function () {
|
|
var button = document.querySelector("#cookieConsent button[data-cookie-string]");
|
|
button.addEventListener("click", function (event) {
|
|
document.cookie = button.dataset.cookieString;
|
|
}, false);
|
|
})();
|
|
</script>
|
|
} |