TLS-Lens/popup/i18n.js

633 lines
28 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/* Runtime localization for the popup UI.
*
* This deliberately does NOT use browser.i18n.getMessage(). That API always
* resolves against the browser UI locale and cannot be overridden at runtime,
* which would break the manual language selector in the settings menu.
*
* _locales/ exists solely for manifest.description, which is read by Firefox
* before any script runs and is therefore unreachable from here. Do not try to
* unify the two mechanisms — the override would be lost.
*/
"use strict";
var I18N = (function() {
const SUPPORTED = ["de", "en"];
const FALLBACK = "en";
const STORAGE_KEY = "language";
const DATE_LOCALES = { de: "de-DE", en: "en-US" };
const MESSAGES = {
de: {
// App chrome
settings_title: "Einstellungen und Aktionen",
menu_language_label: "Sprache",
language_auto: "Automatisch",
menu_theme_label: "Design",
theme_auto: "System",
theme_light: "Hell",
theme_dark: "Dunkel",
menu_copy_report: "Bericht kopieren",
menu_copy_pem: "Zertifikat als PEM kopieren",
menu_copied: "Kopiert ✓",
menu_copy_failed: "Kopieren fehlgeschlagen",
menu_about: "Über TLS Lens",
loading: "Lade …",
not_available: "N/A",
// Tabs
tabs_label: "Bereiche",
tab_overview: "Übersicht",
tab_certificate: "Zertifikat",
tab_chain: "Kette",
tab_san: "SAN",
tab_tech: "Technik",
// Footer and actions
fetched_at: "Abgerufen um {time} Uhr",
action_recheck: "Neu prüfen",
action_retry: "Erneut versuchen",
// About dialog
about_author: "Autor",
about_contact: "Kontakt",
about_license: "Lizenz",
about_version: "Version",
about_date: "Datum",
about_close: "Schließen",
// Full-surface states
state_loading_title: "Zertifikat wird abgerufen …",
state_error_title: "Zertifikat konnte nicht abgerufen werden",
state_http_title: "Keine verschlüsselte Verbindung",
state_http_text: "Diese Seite wird unverschlüsselt über HTTP geladen. Es gibt kein Zertifikat, das geprüft werden kann. Gib hier keine Passwörter oder vertraulichen Daten ein.",
state_blocked_title: "Für diese Seite nicht verfügbar",
state_blocked_text: "Firefox erlaubt Add-ons auf eigenen Seiten (z. B. about:-Seiten oder addons.mozilla.org) keinen Zugriff auf die Verbindungsdaten.",
// Status badge
status_ok: "Sicher",
status_warn: "Warnung",
status_error: "Fehler",
status_unknown: "Unbekannt",
status_insecure: "Nicht sicher",
status_blocked: "Gesperrt",
status_loading: "Lädt",
// Header summary for the non-ready states
summary_loading: "Wird geprüft …",
summary_error: "Keine Daten verfügbar",
summary_http: "Verbindung nicht verschlüsselt",
summary_blocked: "Firefox-interne Seite",
// Limited information notice
limited_title: "Eingeschränkte Informationen",
limited_reason_generic: "Firefox stellt für diese Verbindung nicht alle Details bereit. Einige Angaben fehlen.",
warnings_label: "Warnhinweise",
// Tiles and card titles
tile_protocol: "Protokoll",
tile_issuer: "Aussteller",
card_validity: "Gültigkeit",
card_subject: "Inhaber",
card_issuer: "Aussteller",
card_purpose: "Verwendungszweck",
card_key: "Schlüssel und Signatur",
section_aia: "Authority Information Access (AIA)",
section_san: "Alternative Namen (SAN)",
// Field labels
label_status: "Status",
label_tls_version: "TLS-Version",
label_cipher_suite: "Cipher Suite",
label_ct: "Certificate Transparency",
label_ocsp_query: "OCSP-Abfrage",
label_cn: "Allgemeiner Name (CN)",
label_validation_level: "Validierungsstufe",
label_issuer_o: "Organisation (O)",
label_issuer_cn: "Allgemeiner Name (CN)",
label_issuer_country: "Land",
label_aia_ca: "CA Issuers",
label_aia_ocsp_url: "OCSP-URL",
label_validity_start: "Gültig ab",
label_validity_end: "Gültig bis",
label_remaining: "Restlaufzeit",
label_key_usage: "Key Usage",
label_ext_key_usage: "Extended Key Usage",
label_serial: "Seriennummer",
label_signature: "Signaturalgorithmus",
label_public_key: "Öffentlicher Schlüssel",
label_fingerprint: "Fingerabdruck SHA-256",
ev_short: "EV",
// Explanatory tooltips — one plain sentence per technical term,
// written for readers who have never heard of the concept.
tip_tls_version: "Transport Layer Security – das Verfahren, mit dem die Verbindung zwischen Browser und Server verschlüsselt wird.",
tip_cipher_suite: "Kombination aus Verschlüsselungs- und Prüfverfahren, die Browser und Server für diese Verbindung ausgehandelt haben.",
tip_validation: "Wie gründlich der Aussteller geprüft hat: DV = nur Domain, OV = Organisation, EV = erweiterte Prüfung der Organisation.",
tip_ct_status: "Certificate Transparency: Das Zertifikat ist in öffentlichen Protokollen eingetragen. So fallen heimlich ausgestellte Zertifikate auf.",
tip_ocsp_query: "Online Certificate Status Protocol: Abfrage beim Aussteller, ob das Zertifikat vorzeitig gesperrt wurde.",
tip_cn: "Common Name: der Hauptname, für den das Zertifikat ausgestellt wurde.",
tip_issuer_o: "Organisation, die das Zertifikat ausgestellt hat (Zertifizierungsstelle).",
tip_issuer_cn: "Name des ausstellenden Zertifikats der Zertifizierungsstelle.",
tip_issuer_country: "Der Rechtssitz, den die Zertifizierungsstelle in ihrem eigenen Zertifikat angibt. Er sagt nichts darüber aus, wo die Website oder ihr Server betrieben wird.",
tip_aia: "Authority Information Access: Adressen, unter denen der Browser das ausstellende Zertifikat und den Sperrstatus abrufen kann.",
tip_aia_ocsp: "Adresse für die Sperrabfrage per OCSP. Fehlt sie, prüft Firefox den Sperrstatus über andere Wege.",
tip_san: "Subject Alternative Names: alle Domainnamen und IP-Adressen, für die dieses Zertifikat gültig ist.",
tip_key_usage: "Key Usage: wofür der Schlüssel des Zertifikats grundsätzlich verwendet werden darf, z. B. für digitale Signaturen.",
tip_ext_key_usage: "Extended Key Usage: für welche Anwendungen das Zertifikat bestimmt ist, z. B. Webserver-Authentifizierung.",
tip_serial: "Eindeutige Nummer, die der Aussteller diesem Zertifikat vergeben hat.",
tip_signature: "Verfahren, mit dem der Aussteller das Zertifikat unterschrieben hat.",
tip_public_key: "Art und Stärke des Schlüssels im Zertifikat. Kurze Schlüssel gelten als unsicher.",
tip_fingerprint: "Prüfsumme über das ganze Zertifikat. Damit lässt sich ein Zertifikat eindeutig wiedererkennen.",
// Plain-language summary — assembled from a lead sentence plus an
// issuer sentence plus a validity sentence, so each part stays a
// complete, translatable sentence.
summary_secure: "Verbindung verschlüsselt und vertrauenswürdig.",
summary_weak: "Verschlüsselt, aber mit Schwachstellen.",
summary_broken: "Diese Verbindung ist nicht vertrauenswürdig.",
summary_expired: "Zertifikat abgelaufen oder noch nicht gültig.",
summary_mismatch: "Zertifikat für eine andere Domain ausgestellt.",
summary_untrusted: "Zertifikat von keiner vertrauenswürdigen Stelle.",
// Validity
validation_dv: "Domain validiert (DV)",
validation_ov: "Organisation validiert (OV)",
validation_ev: "Erweitert validiert (EV)",
// Remaining lifetime
remaining_one: "1 Tag",
remaining_other: "{count} Tage",
remaining_today: "Läuft heute ab",
not_after_short: "bis {date}",
// Warnings — title plus explanation, rendered only when a check trips
warn_old_tls_title: "Veraltete TLS-Version",
warn_old_tls: "Die Seite nutzt {version}. Aktuelle Server verwenden TLS 1.2 oder 1.3.",
warn_weak_cipher_title: "Schwache Verschlüsselung",
warn_weak_cipher: "Das Verschlüsselungsverfahren dieser Verbindung gilt als schwach.",
warn_sha1_title: "Schwache Signatur (SHA-1)",
warn_sha1: "Das Zertifikat ist mit SHA-1 signiert. Solche Signaturen lassen sich fälschen.",
warn_md5_title: "Gebrochene Signatur (MD5)",
warn_md5: "Das Zertifikat ist mit MD5 signiert. Dieses Verfahren gilt als gebrochen.",
warn_small_key_title: "Kurzer Schlüssel",
warn_small_key: "Die Schlüssellänge liegt mit {bits} Bit unter dem heute üblichen Mindeststandard von 2048 Bit.",
warn_ct_title: "Certificate Transparency unvollständig",
warn_ct: "Das Zertifikat ist nicht ausreichend in öffentlichen Transparenz-Protokollen eingetragen.",
warn_expiring_title: "Läuft bald ab",
warn_expiring_one: "Das Zertifikat läuft in 1 Tag ab.",
warn_expiring_other: "Das Zertifikat läuft in {count} Tagen ab.",
warn_expires_today_title: "Läuft heute ab",
warn_expires_today: "Das Zertifikat verliert heute seine Gültigkeit.",
warn_expired_title: "Abgelaufen",
warn_expired: "Das Zertifikat ist nicht mehr gültig.",
warn_expired_since_one: "Das Zertifikat ist seit 1 Tag nicht mehr gültig.",
warn_expired_since_other: "Das Zertifikat ist seit {count} Tagen nicht mehr gültig.",
// Validation reasons (limited information)
reason_expired: "Zertifikat ist abgelaufen oder noch nicht gültig",
reason_domain_mismatch: "Domainname stimmt nicht mit dem Zertifikat überein",
reason_untrusted: "Zertifikat wurde von keiner vertrauenswürdigen Zertifizierungsstelle ausgestellt",
// Certificate Transparency
ct_not_applicable: "Nicht anwendbar",
ct_policy_compliant: "Konform",
ct_not_enough_scts: "Nicht genügend SCTs",
ct_not_diverse_scts: "SCTs nicht divers genug",
// Booleans
yes: "Ja",
no: "Nein",
// AIA
aia_not_specified: "Nicht angegeben",
// Issuer tile hint
issuer_hint: "Zwischen-CA {cn} · {country}",
issuer_hint_no_country: "Zwischen-CA {cn}",
// SAN
san_type_ip: "IP",
san_show_more_one: "… 1 weiteren Namen anzeigen",
san_show_more_other: "… {count} weitere Namen anzeigen",
san_show_less: "Weniger anzeigen",
// Certificate chain, rendered root first
chain_intro: "Firefox vertraut dem obersten Zertifikat. Jede Stufe bestätigt die darunter — bis hinunter zum Zertifikat dieser Website.",
chain_root: "Stammzertifikat",
chain_root_trusted: "Stammzertifikat · von Firefox als vertrauenswürdig eingestuft",
chain_intermediate: "Zwischenstelle",
chain_intermediate_of: "Zwischenstelle · {name}",
chain_leaf: "Zertifikat dieser Website · gültig bis {date}",
// Technical details — value templates
key_bits: "{alg}, {bits} Bit",
key_curve: "{alg} ({curve})",
sig_with: "{hash} mit {key}",
// Key usage (2.5.29.15)
ku_digital_signature: "Digitale Signatur",
ku_non_repudiation: "Nichtabstreitbarkeit",
ku_key_encipherment: "Schlüsselverschlüsselung",
ku_data_encipherment: "Datenverschlüsselung",
ku_key_agreement: "Schlüsselaustausch",
ku_key_cert_sign: "Zertifikatssignatur",
ku_crl_sign: "Sperrlistensignatur",
ku_encipher_only: "Nur Verschlüsselung",
ku_decipher_only: "Nur Entschlüsselung",
// Extended key usage (2.5.29.37)
eku_server_auth: "Server-Authentifizierung",
eku_client_auth: "Client-Authentifizierung",
eku_code_signing: "Code-Signatur",
eku_email_protection: "E-Mail-Schutz",
eku_time_stamping: "Zeitstempel",
eku_ocsp_signing: "OCSP-Signatur",
// Country of the issuing CA. The country NAME comes from
// Intl.DisplayNames, so only the surrounding format lives here.
country_value: "{flag} {name} ({code})",
country_value_code_only: "{flag} {code}",
country_source_root: "laut Stammzertifikat",
country_source_chain: "laut übergeordnetem Zertifikat",
// Copied report
report_title: "TLS Lens — Zertifikatsbericht",
report_address: "Adresse",
report_san_count: "Alternative Namen",
report_chain: "Zertifikatskette",
report_warnings: "Hinweise",
// Popup-local errors
err_no_active_tab: "Aktiver Tab konnte nicht ermittelt werden.",
err_no_cert_data: "Die Sicherheitsinformationen dieser Seite waren nicht verfügbar. Lade die Seite neu und versuche es erneut.",
err_cert_unreadable: "Zertifikatsdaten konnten nicht gelesen werden.",
err_unexpected: "Unerwarteter Fehler: {message}",
// Error codes reported by background.js
error_insecure_http: "Diese Verbindung ist nicht sicher (HTTP)",
error_aia_parse_failed: "AIA-Erweiterung konnte nicht gelesen werden.",
error_san_parse_failed: "SAN-Erweiterung konnte nicht gelesen werden.",
error_keyinfo_parse_failed: "Schlüsselinformationen konnten nicht gelesen werden.",
error_keyusage_parse_failed: "Schlüsselverwendung konnte nicht gelesen werden.",
error_cert_info_failed: "Zertifikatsinformationen konnten nicht abgerufen werden.",
error_unknown: "Unbekannter Fehler: {detail}"
},
en: {
// App chrome
settings_title: "Settings and actions",
menu_language_label: "Language",
language_auto: "Automatic",
menu_theme_label: "Theme",
theme_auto: "System",
theme_light: "Light",
theme_dark: "Dark",
menu_copy_report: "Copy report",
menu_copy_pem: "Copy certificate as PEM",
menu_copied: "Copied ✓",
menu_copy_failed: "Copying failed",
menu_about: "About TLS Lens",
loading: "Loading …",
not_available: "N/A",
// Tabs
tabs_label: "Sections",
tab_overview: "Overview",
tab_certificate: "Certificate",
tab_chain: "Chain",
tab_san: "SAN",
tab_tech: "Technical",
// Footer and actions
fetched_at: "Retrieved at {time}",
action_recheck: "Re-check",
action_retry: "Try again",
// About dialog
about_author: "Author",
about_contact: "Contact",
about_license: "License",
about_version: "Version",
about_date: "Date",
about_close: "Close",
// Full-surface states
state_loading_title: "Retrieving certificate …",
state_error_title: "Certificate could not be retrieved",
state_http_title: "Connection is not encrypted",
state_http_text: "This page is loaded over plain HTTP. There is no certificate to inspect. Do not enter passwords or confidential data here.",
state_blocked_title: "Not available for this page",
state_blocked_text: "Firefox does not let add-ons access connection data on its own pages (about: pages or addons.mozilla.org, for example).",
// Status badge
status_ok: "Secure",
status_warn: "Warning",
status_error: "Error",
status_unknown: "Unknown",
status_insecure: "Not secure",
status_blocked: "Blocked",
status_loading: "Loading",
// Header summary for the non-ready states
summary_loading: "Checking …",
summary_error: "No data available",
summary_http: "Connection is not encrypted",
summary_blocked: "Firefox-internal page",
// Limited information notice
limited_title: "Limited information",
limited_reason_generic: "Firefox does not provide full details for this connection. Some values are missing.",
warnings_label: "Warnings",
// Tiles and card titles
tile_protocol: "Protocol",
tile_issuer: "Issuer",
card_validity: "Validity",
card_subject: "Subject",
card_issuer: "Issuer",
card_purpose: "Purpose",
card_key: "Key and signature",
section_aia: "Authority Information Access (AIA)",
section_san: "Subject Alternative Names (SAN)",
// Field labels
label_status: "Status",
label_tls_version: "TLS version",
label_cipher_suite: "Cipher suite",
label_ct: "Certificate Transparency",
label_ocsp_query: "OCSP query",
label_cn: "Common name (CN)",
label_validation_level: "Validation level",
label_issuer_o: "Organization (O)",
label_issuer_cn: "Common name (CN)",
label_issuer_country: "Country",
label_aia_ca: "CA Issuers",
label_aia_ocsp_url: "OCSP URL",
label_validity_start: "Valid from",
label_validity_end: "Valid until",
label_remaining: "Remaining",
label_key_usage: "Key usage",
label_ext_key_usage: "Extended key usage",
label_serial: "Serial number",
label_signature: "Signature algorithm",
label_public_key: "Public key",
label_fingerprint: "Fingerprint SHA-256",
ev_short: "EV",
// Explanatory tooltips — one plain sentence per technical term,
// written for readers who have never heard of the concept.
tip_tls_version: "Transport Layer Security – the method that encrypts the connection between browser and server.",
tip_cipher_suite: "The combination of encryption and verification methods browser and server agreed on for this connection.",
tip_validation: "How thoroughly the issuer checked: DV = domain only, OV = organization, EV = extended check of the organization.",
tip_ct_status: "Certificate Transparency: the certificate is recorded in public logs, so secretly issued certificates stand out.",
tip_ocsp_query: "Online Certificate Status Protocol: a query to the issuer asking whether the certificate was revoked early.",
tip_cn: "Common Name: the main name the certificate was issued for.",
tip_issuer_o: "The organization that issued the certificate (the certificate authority).",
tip_issuer_cn: "Name of the certificate authority's issuing certificate.",
tip_issuer_country: "The legal domicile the certificate authority states in its own certificate. It says nothing about where the website or its server is operated.",
tip_aia: "Authority Information Access: addresses where the browser can fetch the issuing certificate and the revocation status.",
tip_aia_ocsp: "Address for the OCSP revocation query. Without it, Firefox checks revocation by other means.",
tip_san: "Subject Alternative Names: every domain name and IP address this certificate is valid for.",
tip_key_usage: "Key usage: what the certificate's key may fundamentally be used for, such as digital signatures.",
tip_ext_key_usage: "Extended key usage: which applications the certificate is intended for, such as web server authentication.",
tip_serial: "The unique number the issuer assigned to this certificate.",
tip_signature: "The method the issuer used to sign the certificate.",
tip_public_key: "Type and strength of the key in the certificate. Short keys are considered insecure.",
tip_fingerprint: "A checksum over the whole certificate, used to recognise one certificate unambiguously.",
// Plain-language summary — assembled from a lead sentence plus an
// issuer sentence plus a validity sentence, so each part stays a
// complete, translatable sentence.
summary_secure: "Connection encrypted and trustworthy.",
summary_weak: "Encrypted, but with weaknesses.",
summary_broken: "This connection is not trustworthy.",
summary_expired: "Certificate expired or not yet valid.",
summary_mismatch: "Certificate issued for a different domain.",
summary_untrusted: "Certificate not from a trusted authority.",
// Validity
validation_dv: "Domain validated (DV)",
validation_ov: "Organization validated (OV)",
validation_ev: "Extended validation (EV)",
// Remaining lifetime
remaining_one: "1 day",
remaining_other: "{count} days",
remaining_today: "Expires today",
not_after_short: "until {date}",
// Warnings — title plus explanation, rendered only when a check trips
warn_old_tls_title: "Outdated TLS version",
warn_old_tls: "The site uses {version}. Current servers use TLS 1.2 or 1.3.",
warn_weak_cipher_title: "Weak encryption",
warn_weak_cipher: "The encryption method used by this connection is considered weak.",
warn_sha1_title: "Weak signature (SHA-1)",
warn_sha1: "The certificate is signed with SHA-1. Such signatures can be forged.",
warn_md5_title: "Broken signature (MD5)",
warn_md5: "The certificate is signed with MD5. That method is considered broken.",
warn_small_key_title: "Short key",
warn_small_key: "At {bits} bits the key is shorter than today's common minimum of 2048 bits.",
warn_ct_title: "Incomplete Certificate Transparency",
warn_ct: "The certificate is not sufficiently recorded in public transparency logs.",
warn_expiring_title: "Expires soon",
warn_expiring_one: "The certificate expires in 1 day.",
warn_expiring_other: "The certificate expires in {count} days.",
warn_expires_today_title: "Expires today",
warn_expires_today: "The certificate loses its validity today.",
warn_expired_title: "Expired",
warn_expired: "The certificate is no longer valid.",
warn_expired_since_one: "The certificate has been invalid for 1 day.",
warn_expired_since_other: "The certificate has been invalid for {count} days.",
// Validation reasons (limited information)
reason_expired: "Certificate has expired or is not yet valid",
reason_domain_mismatch: "Domain name does not match the certificate",
reason_untrusted: "Certificate was not issued by a trusted certificate authority",
// Certificate Transparency
ct_not_applicable: "Not applicable",
ct_policy_compliant: "Compliant",
ct_not_enough_scts: "Not enough SCTs",
ct_not_diverse_scts: "SCTs not diverse enough",
// Booleans
yes: "Yes",
no: "No",
// AIA
aia_not_specified: "Not specified",
// Issuer tile hint
issuer_hint: "Intermediate CA {cn} · {country}",
issuer_hint_no_country: "Intermediate CA {cn}",
// SAN
san_type_ip: "IP",
san_show_more_one: "… show 1 more name",
san_show_more_other: "… show {count} more names",
san_show_less: "Show fewer",
// Certificate chain, rendered root first
chain_intro: "Firefox trusts the certificate at the top. Each step vouches for the one below it — down to this website’s certificate.",
chain_root: "Root certificate",
chain_root_trusted: "Root certificate · trusted by Firefox",
chain_intermediate: "Intermediate authority",
chain_intermediate_of: "Intermediate authority · {name}",
chain_leaf: "This website’s certificate · valid until {date}",
// Technical details — value templates
key_bits: "{alg}, {bits} bits",
key_curve: "{alg} ({curve})",
sig_with: "{hash} with {key}",
// Key usage (2.5.29.15)
ku_digital_signature: "Digital signature",
ku_non_repudiation: "Non-repudiation",
ku_key_encipherment: "Key encipherment",
ku_data_encipherment: "Data encipherment",
ku_key_agreement: "Key agreement",
ku_key_cert_sign: "Certificate signing",
ku_crl_sign: "CRL signing",
ku_encipher_only: "Encipher only",
ku_decipher_only: "Decipher only",
// Extended key usage (2.5.29.37)
eku_server_auth: "Server authentication",
eku_client_auth: "Client authentication",
eku_code_signing: "Code signing",
eku_email_protection: "Email protection",
eku_time_stamping: "Time stamping",
eku_ocsp_signing: "OCSP signing",
// Country of the issuing CA. The country NAME comes from
// Intl.DisplayNames, so only the surrounding format lives here.
country_value: "{flag} {name} ({code})",
country_value_code_only: "{flag} {code}",
country_source_root: "per root certificate",
country_source_chain: "per issuing chain",
// Copied report
report_title: "TLS Lens — certificate report",
report_address: "Address",
report_san_count: "Alternative names",
report_chain: "Certificate chain",
report_warnings: "Findings",
// Popup-local errors
err_no_active_tab: "Could not determine the active tab.",
err_no_cert_data: "The security information for this page was not available. Reload the page and try again.",
err_cert_unreadable: "Certificate data could not be read.",
err_unexpected: "Unexpected error: {message}",
// Error codes reported by background.js
error_insecure_http: "This connection is not secure (HTTP)",
error_aia_parse_failed: "Could not parse the AIA extension.",
error_san_parse_failed: "Could not parse the SAN extension.",
error_keyinfo_parse_failed: "Could not read the key information.",
error_keyusage_parse_failed: "Could not read the key usage.",
error_cert_info_failed: "Failed to retrieve certificate information.",
error_unknown: "Unknown error: {detail}"
}
};
// "auto" | "de" | "en" — what the user selected
var setting = "auto";
// "de" | "en" — what is actually rendered
var lang = FALLBACK;
// Browser UI language, narrowed to a supported language.
// Anything else (e.g. "fr") falls back to English.
function detect() {
var ui = "";
try {
ui = browser.i18n.getUILanguage() || "";
} catch (e) {
/* i18n unavailable — fall through to navigator.language */
}
if (!ui) {
ui = navigator.language || "";
}
var base = ui.toLowerCase().split(/[-_]/)[0];
return SUPPORTED.indexOf(base) !== -1 ? base : FALLBACK;
}
function normalize(value) {
return SUPPORTED.indexOf(value) !== -1 ? value : "auto";
}
function resolve(value) {
return value === "auto" ? detect() : value;
}
// Must complete before the first text is rendered, otherwise the wrong
// language flashes up briefly.
async function init() {
var stored = "auto";
try {
var result = await browser.storage.local.get(STORAGE_KEY);
if (result && typeof result[STORAGE_KEY] === "string") {
stored = result[STORAGE_KEY];
}
} catch (e) {
/* storage unavailable — stay on automatic detection */
}
setting = normalize(stored);
lang = resolve(setting);
return lang;
}
async function setSetting(value) {
setting = normalize(value);
lang = resolve(setting);
try {
await browser.storage.local.set({ [STORAGE_KEY]: setting });
} catch (e) {
console.warn("TLS Lens: Could not persist language setting:", e);
}
return lang;
}
function t(key, params) {
var table = MESSAGES[lang] || MESSAGES[FALLBACK];
var text = table[key];
if (text === undefined) {
text = MESSAGES[FALLBACK][key];
}
if (text === undefined) {
return key;
}
if (!params) {
return text;
}
return text.replace(/\{(\w+)\}/g, function(match, name) {
return Object.prototype.hasOwnProperty.call(params, name)
? String(params[name])
: match;
});
}
// Two plural forms are enough for de/en ("1 weiterer" vs "N weitere").
function tn(baseKey, count, params) {
var merged = Object.assign({ count: count }, params || {});
return t(baseKey + (count === 1 ? "_one" : "_other"), merged);
}
function dateLocale() {
return DATE_LOCALES[lang] || DATE_LOCALES[FALLBACK];
}
return {
init: init,
setSetting: setSetting,
t: t,
tn: tn,
dateLocale: dateLocale,
get lang() { return lang; },
get setting() { return setting; }
};
})();