#!/usr/bin/env python3
"""
Erstellt die _locales-Verzeichnisse für die Pedantic Picture Packer Thunderbird-Erweiterung.
Unterstützt 35 Sprachen.

Voll übersetzt / angepasst: de, en, es, fr, it, pt, ru, zh, ja (9 Sprachen)
Englisch als Basis: nl, pl, sv, tr, ar, hi, vi, th, ko, id, uk, cs, el,
                    he, fi, da, no, hu, ro, sk, bg, hr, sl, lt, lv, et (26 Sprachen)

Ausgabe:
    _locales/<lang>/messages.json

Verwendung:
    python create_locales.py [output_dir]
    output_dir  Standard: . (aktuelles Verzeichnis)
"""

import json
import os
import sys


def make_locale(base, overrides):
    """
    Erstellt ein neues Locale-Dict auf Basis von `base`.
    Übernimmt Nachrichten aus `overrides` und behält Platzhalter & Beschreibungen aus `base` bei.
    """
    res = {}
    for k, v in base.items():
        res[k] = dict(v)
    for k, v in overrides.items():
        msg = v["message"] if isinstance(v, dict) and "message" in v else v
        if k in res:
            res[k]["message"] = msg
        else:
            if isinstance(v, dict):
                res[k] = dict(v)
            else:
                res[k] = {"message": msg}
    return res


# ── Deutsch (default_locale) ──────────────────────────────────

DE = {
  "extensionName": {
    "message": "Pedantic Picture Packer"
  },
  "extensionDescription": {
    "message": "State of the art Bildkompression mit JPEGli, PNGquant und oxipng."
  },
  "options_general": {
    "message": "Allgemein",
    "description": "options.html legend"
  },
  "sendMode_ask": {
    "message": "Vor dem Senden an unerledigte Punkte erinnern",
    "description": "Radio label for sendMode=ask"
  },
  "sendMode_auto": {
    "message": "Alle Aktionen ohne Rückfrage vor dem Versand ausführen",
    "description": "Radio label for sendMode=auto"
  },
  "sendMode_manual": {
    "message": "Ich erledige alles manuell über den Button im Nachrichtenfenster",
    "description": "Radio label for sendMode=manual"
  },
  "label_minFileSize": {
    "message": "Min. Dateigröße (KB):",
    "description": "options.html field label"
  },
  "label_minSavingsPercent": {
    "message": "Min. Einsparung (%):",
    "description": "options.html field label"
  },
  "label_replaceText": {
    "message": "Ersatztext für entfernte Bilder in Zitaten:",
    "description": "options.html field label"
  },
  "options_attachments": {
    "message": "Bilder im Anhang",
    "description": "options.html legend"
  },
  "options_inline": {
    "message": "Inline-Bilder",
    "description": "options.html legend"
  },
  "options_quotes": {
    "message": "Bilder in Zitaten",
    "description": "options.html legend"
  },
  "label_compressionProfile": {
    "message": "Kompressionsprofil:",
    "description": "options.html field label (appears 3x)"
  },
  "options_editProfile": {
    "message": "Kompressionsprofil bearbeiten",
    "description": "options.html legend"
  },
  "btn_delete": {
    "message": "Löschen",
    "description": "options.html button"
  },
  "label_preserveMeta": {
    "message": "Meta-Daten behalten (EXIF, ICC, XMP)",
    "description": "options.html checkbox"
  },
  "label_crossConvert": {
    "message": "Cross-Konvertierung erlauben (PNG ↔ JPG), wenn es Speicher spart",
    "description": "options.html checkbox"
  },
  "sublabel_antiAlias": {
    "message": "AntiAlias",
    "description": "options.html sub-label"
  },
  "label_antialiasing": {
    "message": "Antialiasing (Faktor 1.0–2.0):",
    "description": "options.html field label"
  },
  "label_scaleToDisplay": {
    "message": "Große Bilder auf Anzeigegröße herunterskalieren (gilt nicht für Bilder im Anhang)",
    "description": "options.html checkbox"
  },
  "sublabel_resize": {
    "message": "Resize",
    "description": "options.html sub-label"
  },
  "label_resizeAlgorithm": {
    "message": "Resize-Algorithmus:",
    "description": "options.html field label"
  },
  "sublabel_jpegli": {
    "message": "JPEGli",
    "description": "options.html sub-label"
  },
  "label_jpegQuality": {
    "message": "JPEG-Qualität:",
    "description": "options.html field label"
  },
  "label_chromaSubsampling": {
    "message": "Chroma-Subsampling:",
    "description": "options.html field label"
  },
  "sublabel_pngquant": {
    "message": "PNGquant",
    "description": "options.html sub-label"
  },
  "label_maxColors": {
    "message": "Max. Farben:",
    "description": "options.html field label"
  },
  "label_minQuality": {
    "message": "Min. Qualität:",
    "description": "options.html field label"
  },
  "label_maxQuality": {
    "message": "Max. Qualität:",
    "description": "options.html field label"
  },
  "label_dithering": {
    "message": "Dithering:",
    "description": "options.html field label"
  },
  "label_speed": {
    "message": "Speed (höher = schneller):",
    "description": "options.html field label"
  },
  "sublabel_oxipng": {
    "message": "OxiPNG",
    "description": "options.html sub-label"
  },
  "label_oxipngAlpha": {
    "message": "Alpha-Optimierung (visuell verlustfrei)",
    "description": "options.html checkbox"
  },
  "label_optimizationLevel": {
    "message": "Optimierungs-Level:",
    "description": "options.html field label"
  },
  "btn_saveAs": {
    "message": "Speichern unter:",
    "description": "options.html button"
  },
  "label_name": {
    "message": "Name:",
    "description": "options.html span"
  },
  "placeholder_templateName": {
    "message": "Profilname",
    "description": "options.html input placeholder"
  },
  "btn_exportProfiles": {
    "message": "Profile exportieren",
    "description": "options.html button"
  },
  "btn_importProfiles": {
    "message": "Profile importieren",
    "description": "options.html button"
  },
  "options_exclusions": {
    "message": "Dauerhafte Ausnahmen",
    "description": "options.html legend"
  },
  "label_excludedImages": {
    "message": "Ausgeschlossene Bilder:",
    "description": "options.html info text"
  },
  "btn_clearList": {
    "message": "Liste leeren",
    "description": "options.html button"
  },
  "text_saved": {
    "message": "Gespeichert",
    "description": "options.html saved indicator"
  },
  "btn_resetToDefault": {
    "message": "Auf Standard zurücksetzen",
    "description": "options.html button"
  },
  "appName": {
    "message": "Pedantic Picture Packer",
    "description": "popup.html header"
  },
  "btn_settings": {
    "message": "Einstellungen",
    "description": "popup.html settings link"
  },
  "popup_behavior": {
    "message": "Verhalten",
    "description": "popup.html legend"
  },
  "popup_profiles": {
    "message": "Profile",
    "description": "popup.html legend"
  },
  "cat_attachment": {
    "message": "Anhang",
    "description": "Category label: attachment"
  },
  "cat_inline": {
    "message": "Inline",
    "description": "Category label: inline"
  },
  "cat_quote": {
    "message": "Zitat",
    "description": "Category label: quote"
  },
  "popup_resample": {
    "message": "Resample",
    "description": "popup.html legend"
  },
  "text_noImagesFound": {
    "message": "Keine Bilder zum Komprimieren gefunden.",
    "description": "Empty state text"
  },
  "btn_applyAll": {
    "message": "Alle anwenden",
    "description": "popup.html button"
  },
  "text_processing": {
    "message": "Wird verarbeitet...",
    "description": "Loading overlay default text"
  },
  "confirmSend_title": {
    "message": "Bilderkompression",
    "description": "confirmSend.html header"
  },
  "btn_cancel": {
    "message": "Abbrechen",
    "description": "confirmSend.html button"
  },
  "btn_send": {
    "message": "Senden",
    "description": "confirmSend.html button"
  },
  "btn_applyAllAndSend": {
    "message": "Alle anwenden und senden",
    "description": "confirmSend.html button"
  },
  "loading_imagesLoading": {
    "message": "Bilder werden geladen...",
    "description": "Loading text in popup/confirmSend init"
  },
  "col_type": {
    "message": "Typ",
    "description": "Param table header"
  },
  "col_size": {
    "message": "Größe",
    "description": "Param table header"
  },
  "col_resolution": {
    "message": "Auflösung",
    "description": "Param table header"
  },
  "col_inlineResolution": {
    "message": "Inline-Auflösung",
    "description": "Param table header"
  },
  "col_savings": {
    "message": "Ersparnis",
    "description": "Param table header"
  },
  "summary_compressed": {
    "message": "komprimiert",
    "description": "Summary: N compressed"
  },
  "summary_removed": {
    "message": "entfernt",
    "description": "Summary: N removed"
  },
  "summary_excluded": {
    "message": "ausgenommen",
    "description": "Summary: N excluded"
  },
  "summary_saved": {
    "message": "gespart",
    "description": "Summary: N bytes saved"
  },
  "summary_noChanges": {
    "message": "Keine Änderungen",
    "description": "Summary fallback"
  },
  "badge_incompressible": {
    "message": "inkompressibel",
    "description": "Badge for incompressible images"
  },
  "badge_excluded": {
    "message": "ausgenommen",
    "description": "Badge for excluded images"
  },
  "state_removed": {
    "message": "Entfernt",
    "description": "After-row label for removed images"
  },
  "state_excluded": {
    "message": "Ausgenommen",
    "description": "After-row label for excluded images"
  },
  "btn_removeExclusion": {
    "message": "Ausnahme entfernen",
    "description": "Button to unexclude an image"
  },
  "btn_restore": {
    "message": "Wiederherstellen",
    "description": "Button to restore an image"
  },
  "btn_undo": {
    "message": "Rückgängig",
    "description": "Button to undo compression"
  },
  "btn_apply": {
    "message": "Anwenden",
    "description": "Button to apply compression"
  },
  "btn_exclude": {
    "message": "Ausnahme",
    "description": "Button to exclude an image"
  },
  "title_exclude": {
    "message": "Dieses Bild dauerhaft von der Kompression ausnehmen",
    "description": "Exclude button tooltip"
  },
  "title_download": {
    "message": "Bild herunterladen",
    "description": "Download button tooltip"
  },
  "label_resize": {
    "message": "Resize",
    "description": "Card control label"
  },
  "label_profile": {
    "message": "Profil",
    "description": "Card control label"
  },
  "card_keepMeta": {
    "message": "Keep meta",
    "description": "Checkbox label on image card"
  },
  "title_keepMeta": {
    "message": "Metadaten behalten (EXIF, ICC, XMP)",
    "description": "Keep-meta checkbox tooltip"
  },
  "card_shrinkToInline": {
    "message": "shrink to inline",
    "description": "Checkbox label on image card"
  },
  "title_shrinkToInline": {
    "message": "Auf inline Auflösung herunterskalieren (nur Inline/Zitat)",
    "description": "Shrink-to-inline checkbox tooltip"
  },
  "card_keepDimension": {
    "message": "keep dimension",
    "description": "Checkbox label on image card"
  },
  "title_keepDimension": {
    "message": "Anzeigegröße im HTML beibehalten",
    "description": "Keep-dimension checkbox tooltip"
  },
  "card_forcePng": {
    "message": "Force PNG",
    "description": "Checkbox label on image card"
  },
  "title_forcePng": {
    "message": "Bild zwangsweise als PNG speichern (JPEG→PNG, PNG bleibt PNG, kein JPEG-Versuch, Ergebnis wird auch ohne Verkleinerung übernommen)",
    "description": "Force-PNG checkbox tooltip"
  },
  "label_antiAlias": {
    "message": "AntiAlias",
    "description": "Card resize label when in AntiAlias mode"
  },
  "btn_showExcluded": {
    "message": "Ausnahme einblenden ($1)",
    "description": "Button to show excluded images, $1=count",
    "placeholders": {
      "count": {
        "content": "$1"
      }
    }
  },
  "loading_showingExclusions": {
    "message": "Ausnahmen werden eingeblendet...",
    "description": "Loading text"
  },
  "progress_done": {
    "message": "Fertig",
    "description": "Progress complete text"
  },
  "loading_compressing": {
    "message": "$1 wird komprimiert...",
    "description": "Loading: image being compressed, $1=name",
    "placeholders": {
      "name": {
        "content": "$1"
      }
    }
  },
  "loading_restoring": {
    "message": "$1 wird wiederhergestellt...",
    "description": "Loading: image being restored, $1=name",
    "placeholders": {
      "name": {
        "content": "$1"
      }
    }
  },
  "alert_errorAt": {
    "message": "Fehler bei $1: $2",
    "description": "Alert: error for image, $1=name $2=error",
    "placeholders": {
      "name": {
        "content": "$1"
      },
      "error": {
        "content": "$2"
      }
    }
  },
  "text_unknown": {
    "message": "Unbekannt",
    "description": "Unknown error fallback"
  },
  "unit_bytes": {
    "message": "B",
    "description": "Byte unit suffix"
  },
  "unit_kilobytes": {
    "message": "KB",
    "description": "Kilobyte unit suffix"
  },
  "unit_megabytes": {
    "message": "MB",
    "description": "Megabyte unit suffix"
  },
  "error_noComposeWindow": {
    "message": "Kein Verfassen-Fenster offen.",
    "description": "popup.js error"
  },
  "loading_preparingSend": {
    "message": "Senden wird vorbereitet...",
    "description": "confirmSend.js loading text"
  },
  "error_prefix": {
    "message": "Fehler: $1",
    "description": "confirmSend.js error display, $1=message",
    "placeholders": {
      "message": {
        "content": "$1"
      }
    }
  },
  "alert_noProfilesToExport": {
    "message": "Keine eigenen Profile zum Exportieren vorhanden.",
    "description": "options.js alert"
  },
  "alert_invalidFileFormat": {
    "message": "Ungültiges Dateiformat. JSON mit Profil-Definitionen erwartet.",
    "description": "options.js alert"
  },
  "alert_noProfilesImported": {
    "message": "Keine Profile importiert. $1",
    "description": "options.js alert, $1=skipped info",
    "placeholders": {
      "skipped": {
        "content": "$1"
      }
    }
  },
  "alert_profilesImported": {
    "message": "$1 Profil(e) importiert",
    "description": "options.js alert, $1=count",
    "placeholders": {
      "count": {
        "content": "$1"
      }
    }
  },
  "text_overwritten": {
    "message": "überschrieben",
    "description": "options.js import result"
  },
  "text_skipped": {
    "message": "übersprungen",
    "description": "options.js import result"
  },
  "alert_importError": {
    "message": "Fehler beim Import: $1",
    "description": "options.js alert, $1=error message",
    "placeholders": {
      "error": {
        "content": "$1"
      }
    }
  },
  "alert_fileReadError": {
    "message": "Datei konnte nicht gelesen werden.",
    "description": "options.js alert"
  },
  "resize_auto": {
    "message": "Auto (PNG: Mitchell, JPG: Lanczos)",
    "description": "Resize algorithm label"
  },
  "resize_lanczos": {
    "message": "Lanczos (höchste Qualität, langsam)",
    "description": "Resize algorithm label"
  },
  "resize_mitchell": {
    "message": "Mitchell-Netravali (weich, detailerhaltend)",
    "description": "Resize algorithm label"
  },
  "resize_bicubic": {
    "message": "Bicubic (hohe Qualität, browser-nativ)",
    "description": "Resize algorithm label"
  },
  "resize_bilinear": {
    "message": "Bilinear (mittel, browser-nativ)",
    "description": "Resize algorithm label"
  },
  "resize_nearest": {
    "message": "Nearest-Neighbor (Pixel-Art, browser-nativ)",
    "description": "Resize algorithm label"
  },
  "error_imageNotFound": {
    "message": "Bild nicht gefunden",
    "description": "background.js error"
  },
  "error_fileNotAvailable": {
    "message": "Datei nicht verfügbar",
    "description": "background.js error"
  },
  "error_imageNotAccessible": {
    "message": "Bild nicht abrufbar",
    "description": "background.js error"
  },
  "error_composeScriptUnreachable": {
    "message": "Compose-Skript nicht erreichbar",
    "description": "background.js error"
  },
  "error_compressionFailedForcePng": {
    "message": "Kompression fehlgeschlagen (force png)",
    "description": "background.js error"
  },
  "error_noReduction": {
    "message": "Keine Verkleinerung",
    "description": "background.js error"
  },
  "default_replaceText": {
    "message": "Image removed",
    "description": "Default replacement text for removed images"
  },
  "profile_removeImage": {
    "message": "remove Image",
    "description": "Profile name: remove image (also used as identifier — needs special handling)"
  },
  "profile_doNothing": {
    "message": "do nothing",
    "description": "Profile name: do nothing (also used as identifier — needs special handling)"
  },
  "imgname_quote": {
    "message": "zitat-bild",
    "description": "Internal name for quote images"
  },
  "imgname_inline": {
    "message": "inline-bild",
    "description": "Internal name for inline images"
  },
  "error_notCompressible": {
    "message": "Nicht komprimierbar",
    "description": "composeScript.js error"
  },
  "error_noCachedResult": {
    "message": "Kein komprimiertes Ergebnis im Cache",
    "description": "composeScript.js error"
  },
  "error_noEncodingSuccess": {
    "message": "Keine Encodierung erfolgreich",
    "description": "worker.js error"
  },
  "error_wasmFetchFailed": {
    "message": "WASM fetch fehlgeschlagen: $1",
    "description": "worker.js error, $1=status+url",
    "placeholders": {
      "detail": {
        "content": "$1"
      }
    }
  },
  "error_cjpegliMallocFailed": {
    "message": "cjpegli: malloc fehlgeschlagen — Speicher voll?",
    "description": "worker.js error"
  },
  "error_cjpegliEncodeFailed": {
    "message": "cjpegli: encode fehlgeschlagen — $1",
    "description": "worker.js error, $1=detail",
    "placeholders": {
      "detail": {
        "content": "$1"
      }
    }
  },
  "error_cjpegliInvalidJpeg": {
    "message": "cjpegli: ungültiger JPEG-Header",
    "description": "worker.js error"
  },
  "error_libimagequantNoResult": {
    "message": "libimagequant: kein PNG-Ergebnis: $1",
    "description": "worker.js error, $1=keys",
    "placeholders": {
      "keys": {
        "content": "$1"
      }
    }
  },
  "error_workerError": {
    "message": "Worker-Fehler: $1",
    "description": "background.js worker error wrapper, $1=message",
    "placeholders": {
      "message": {
        "content": "$1"
      }
    }
  }
}


# ── Englisch (Basis für 26 weitere Sprachen) ─────────────────

EN_OVERRIDES = {
    "extensionDescription": "State-of-the-art image compression with JPEGli, PNGquant, and OxiPNG.",
    "options_general": "General",
    "sendMode_ask": "Remind about unprocessed items before sending",
    "sendMode_auto": "Execute all actions without confirmation before sending",
    "sendMode_manual": "I handle everything manually via the button in the compose window",
    "label_minFileSize": "Min. file size (KB):",
    "label_minSavingsPercent": "Min. savings (%):",
    "label_replaceText": "Replacement text for removed quote images:",
    "options_attachments": "Attachment images",
    "options_inline": "Inline images",
    "options_quotes": "Quote images",
    "label_compressionProfile": "Compression profile:",
    "options_editProfile": "Edit compression profile",
    "btn_delete": "Delete",
    "label_preserveMeta": "Preserve metadata (EXIF, ICC, XMP)",
    "label_crossConvert": "Allow cross-conversion (PNG ↔ JPG) if it saves space",
    "label_antialiasing": "Antialiasing (factor 1.0–2.0):",
    "label_scaleToDisplay": "Downscale large images to display size (does not apply to attachments)",
    "label_resizeAlgorithm": "Resize algorithm:",
    "label_jpegQuality": "JPEG quality:",
    "label_chromaSubsampling": "Chroma subsampling:",
    "label_maxColors": "Max. colors:",
    "label_minQuality": "Min. quality:",
    "label_maxQuality": "Max. quality:",
    "label_dithering": "Dithering:",
    "label_speed": "Speed (higher = faster):",
    "label_oxipngAlpha": "Alpha optimization (visually lossless)",
    "label_optimizationLevel": "Optimization level:",
    "btn_saveAs": "Save as:",
    "label_name": "Name:",
    "placeholder_templateName": "Profile name",
    "btn_exportProfiles": "Export profiles",
    "btn_importProfiles": "Import profiles",
    "options_exclusions": "Permanent exclusions",
    "label_excludedImages": "Excluded images:",
    "btn_clearList": "Clear list",
    "text_saved": "Saved",
    "btn_resetToDefault": "Reset to default",
    "btn_settings": "Settings",
    "popup_behavior": "Behavior",
    "popup_profiles": "Profiles",
    "cat_attachment": "Attachment",
    "cat_inline": "Inline",
    "cat_quote": "Quote",
    "text_noImagesFound": "No images found to compress.",
    "btn_applyAll": "Apply all",
    "text_processing": "Processing...",
    "confirmSend_title": "Image compression",
    "btn_cancel": "Cancel",
    "btn_send": "Send",
    "btn_applyAllAndSend": "Apply all and send",
    "loading_imagesLoading": "Loading images...",
    "col_type": "Type",
    "col_size": "Size",
    "col_resolution": "Resolution",
    "col_inlineResolution": "Inline resolution",
    "col_savings": "Savings",
    "summary_compressed": "compressed",
    "summary_removed": "removed",
    "summary_excluded": "excluded",
    "summary_saved": "saved",
    "summary_noChanges": "No changes",
    "badge_incompressible": "incompressible",
    "badge_excluded": "excluded",
    "state_removed": "Removed",
    "state_excluded": "Excluded",
    "btn_removeExclusion": "Remove exclusion",
    "btn_restore": "Restore",
    "btn_undo": "Undo",
    "btn_apply": "Apply",
    "btn_exclude": "Exclude",
    "title_exclude": "Permanently exclude this image from compression",
    "title_download": "Download image",
    "label_profile": "Profile",
    "title_keepMeta": "Keep metadata (EXIF, ICC, XMP)",
    "title_shrinkToInline": "Downscale to inline resolution (inline/quote only)",
    "title_keepDimension": "Keep display size in HTML",
    "title_forcePng": "Force image to save as PNG (JPEG→PNG, PNG stays PNG, no JPEG attempt, result applied even without size reduction)",
    "btn_showExcluded": "Show exclusion ($1)",
    "loading_showingExclusions": "Showing exclusions...",
    "progress_done": "Done",
    "loading_compressing": "Compressing $1...",
    "loading_restoring": "Restoring $1...",
    "alert_errorAt": "Error on $1: $2",
    "text_unknown": "Unknown",
    "error_noComposeWindow": "No compose window open.",
    "loading_preparingSend": "Preparing send...",
    "error_prefix": "Error: $1",
    "alert_noProfilesToExport": "No custom profiles available to export.",
    "alert_invalidFileFormat": "Invalid file format. Expected JSON with profile definitions.",
    "alert_noProfilesImported": "No profiles imported. $1",
    "alert_profilesImported": "Imported $1 profile(s)",
    "text_overwritten": "overwritten",
    "text_skipped": "skipped",
    "alert_importError": "Import error: $1",
    "alert_fileReadError": "Could not read file.",
    "resize_lanczos": "Lanczos (highest quality, slow)",
    "resize_mitchell": "Mitchell-Netravali (soft, detail-preserving)",
    "resize_bicubic": "Bicubic (high quality, browser-native)",
    "resize_bilinear": "Bilinear (medium, browser-native)",
    "resize_nearest": "Nearest-Neighbor (pixel art, browser-native)",
    "error_imageNotFound": "Image not found",
    "error_fileNotAvailable": "File not available",
    "error_imageNotAccessible": "Image not accessible",
    "error_composeScriptUnreachable": "Compose script unreachable",
    "error_compressionFailedForcePng": "Compression failed (force png)",
    "error_noReduction": "No size reduction",
    "imgname_quote": "quote-image",
    "imgname_inline": "inline-image",
    "error_notCompressible": "Not compressible",
    "error_noCachedResult": "No compressed result in cache",
    "error_noEncodingSuccess": "No encoding successful",
    "error_wasmFetchFailed": "WASM fetch failed: $1",
    "error_cjpegliMallocFailed": "cjpegli: malloc failed — out of memory?",
    "error_cjpegliEncodeFailed": "cjpegli: encode failed — $1",
    "error_cjpegliInvalidJpeg": "cjpegli: invalid JPEG header",
    "error_libimagequantNoResult": "libimagequant: no PNG result: $1",
    "error_workerError": "Worker error: $1"
}


# ── Spanisch ──────────────────────────────────────────────────

ES_OVERRIDES = {
    "extensionDescription": "Compresión de imágenes de vanguardia con JPEGli, PNGquant y OxiPNG.",
    "options_general": "General",
    "sendMode_ask": "Recordar elementos pendientes antes de enviar",
    "sendMode_auto": "Ejecutar todas las acciones sin confirmación antes de enviar",
    "sendMode_manual": "Gestiono todo manualmente con el botón de la ventana de redacción",
    "label_minFileSize": "Tamaño mín. de archivo (KB):",
    "label_minSavingsPercent": "Ahorro mín. (%):",
    "label_replaceText": "Texto de sustitución para imágenes de citas eliminadas:",
    "options_attachments": "Imágenes en adjuntos",
    "options_inline": "Imágenes en línea",
    "options_quotes": "Imágenes en citas",
    "label_compressionProfile": "Perfil de compresión:",
    "options_editProfile": "Editar perfil de compresión",
    "btn_delete": "Eliminar",
    "label_preserveMeta": "Conservar metadatos (EXIF, ICC, XMP)",
    "label_crossConvert": "Permitir conversión cruzada (PNG ↔ JPG) si ahorra espacio",
    "label_antialiasing": "Antialiasing (factor 1.0–2.0):",
    "label_scaleToDisplay": "Reducir imágenes grandes al tamaño de visualización (no se aplica a adjuntos)",
    "label_resizeAlgorithm": "Algoritmo de redimensionado:",
    "label_jpegQuality": "Calidad JPEG:",
    "label_chromaSubsampling": "Submuestreo de croma:",
    "label_maxColors": "Máx. colores:",
    "label_minQuality": "Calidad mín.:",
    "label_maxQuality": "Calidad máx.:",
    "label_dithering": "Dithering:",
    "label_speed": "Velocidad (mayor = más rápido):",
    "label_oxipngAlpha": "Optimización alfa (visualmente sin pérdidas)",
    "label_optimizationLevel": "Nivel de optimización:",
    "btn_saveAs": "Guardar como:",
    "label_name": "Nombre:",
    "placeholder_templateName": "Nombre del perfil",
    "btn_exportProfiles": "Exportar perfiles",
    "btn_importProfiles": "Importar perfiles",
    "options_exclusions": "Exclusiones permanentes",
    "label_excludedImages": "Imágenes excluidas:",
    "btn_clearList": "Vaciar lista",
    "text_saved": "Guardado",
    "btn_resetToDefault": "Restablecer valores predeterminados",
    "btn_settings": "Ajustes",
    "popup_behavior": "Comportamiento",
    "popup_profiles": "Perfiles",
    "cat_attachment": "Adjunto",
    "cat_inline": "En línea",
    "cat_quote": "Cita",
    "text_noImagesFound": "No se encontraron imágenes para comprimir.",
    "btn_applyAll": "Aplicar todo",
    "text_processing": "Procesando...",
    "confirmSend_title": "Compresión de imágenes",
    "btn_cancel": "Cancelar",
    "btn_send": "Enviar",
    "btn_applyAllAndSend": "Aplicar todo y enviar",
    "loading_imagesLoading": "Cargando imágenes...",
    "col_type": "Tipo",
    "col_size": "Tamaño",
    "col_resolution": "Resolución",
    "col_inlineResolution": "Resolución en línea",
    "col_savings": "Ahorro",
    "summary_compressed": "comprimido",
    "summary_removed": "eliminado",
    "summary_excluded": "excluido",
    "summary_saved": "guardado",
    "summary_noChanges": "Sin cambios",
    "badge_incompressible": "incomprimible",
    "badge_excluded": "excluido",
    "state_removed": "Eliminado",
    "state_excluded": "Excluido",
    "btn_removeExclusion": "Eliminar exclusión",
    "btn_restore": "Restaurar",
    "btn_undo": "Deshacer",
    "btn_apply": "Aplicar",
    "btn_exclude": "Excepción",
    "title_exclude": "Excluir esta imagen permanentemente de la compresión",
    "title_download": "Descargar imagen",
    "label_profile": "Perfil",
    "title_keepMeta": "Conservar metadatos (EXIF, ICC, XMP)",
    "title_shrinkToInline": "Reducir a resolución en línea (solo en línea/cita)",
    "title_keepDimension": "Mantener tamaño de visualización en HTML",
    "btn_showExcluded": "Mostrar exclusión ($1)",
    "loading_showingExclusions": "Mostrando exclusiones...",
    "progress_done": "Hecho",
    "loading_compressing": "Comprimiendo $1...",
    "loading_restoring": "Restaurando $1...",
    "alert_errorAt": "Error en $1: $2",
    "text_unknown": "Desconocido",
    "error_noComposeWindow": "No hay ventana de redacción abierta.",
    "loading_preparingSend": "Preparando envío...",
    "error_prefix": "Error: $1"
}


# ── Französisch ──────────────────────────────────────────────

FR_OVERRIDES = {
    "extensionDescription": "Compression d'images de pointe avec JPEGli, PNGquant et OxiPNG.",
    "options_general": "Général",
    "sendMode_ask": "Rappeler les éléments non traités avant l'envoi",
    "sendMode_auto": "Exécuter toutes les actions sans confirmation avant l'envoi",
    "sendMode_manual": "Je gère tout manuellement via le bouton de la fenêtre de rédaction",
    "label_minFileSize": "Taille min. de fichier (Ko) :",
    "label_minSavingsPercent": "Économie min. (%) :",
    "label_replaceText": "Texte de remplacement pour les images de citation supprimées :",
    "options_attachments": "Images en pièce jointe",
    "options_inline": "Images intégrées",
    "options_quotes": "Images dans les citations",
    "label_compressionProfile": "Profil de compression :",
    "options_editProfile": "Modifier le profil de compression",
    "btn_delete": "Supprimer",
    "label_preserveMeta": "Conserver les métadonnées (EXIF, ICC, XMP)",
    "label_crossConvert": "Autoriser la conversion croisée (PNG ↔ JPG) si cela économise de l'espace",
    "label_antialiasing": "Antialiasing (facteur 1.0–2.0) :",
    "label_scaleToDisplay": "Réduire les grandes images à la taille d'affichage (ne s'applique pas aux pièces jointes)",
    "label_resizeAlgorithm": "Algorithme de redimensionnement :",
    "label_jpegQuality": "Qualité JPEG :",
    "label_chromaSubsampling": "Sous-échantillonnage chroma :",
    "label_maxColors": "Couleurs max. :",
    "label_minQuality": "Qualité min. :",
    "label_maxQuality": "Qualité max. :",
    "label_dithering": "Tramage :",
    "label_speed": "Vitesse (plus élevé = plus rapide) :",
    "label_oxipngAlpha": "Optimisation alpha (visuellement sans perte)",
    "label_optimizationLevel": "Niveau d'optimisation :",
    "btn_saveAs": "Enregistrer sous :",
    "label_name": "Nom :",
    "placeholder_templateName": "Nom du profil",
    "btn_exportProfiles": "Exporter les profils",
    "btn_importProfiles": "Importer des profils",
    "options_exclusions": "Exclusions permanentes",
    "label_excludedImages": "Images exclues :",
    "btn_clearList": "Vider la liste",
    "text_saved": "Enregistré",
    "btn_resetToDefault": "Réinitialiser aux valeurs par défaut",
    "btn_settings": "Paramètres",
    "popup_behavior": "Comportement",
    "popup_profiles": "Profils",
    "cat_attachment": "Pièce jointe",
    "cat_inline": "Intégré",
    "cat_quote": "Citation",
    "text_noImagesFound": "Aucune image trouvée à compresser.",
    "btn_applyAll": "Tout appliquer",
    "text_processing": "Traitement en cours...",
    "confirmSend_title": "Compression d'images",
    "btn_cancel": "Annuler",
    "btn_send": "Envoyer",
    "btn_applyAllAndSend": "Tout appliquer et envoyer",
    "loading_imagesLoading": "Chargement des images...",
    "col_type": "Type",
    "col_size": "Taille",
    "col_resolution": "Résolution",
    "col_inlineResolution": "Résolution intégrée",
    "col_savings": "Économie",
    "summary_compressed": "compressé",
    "summary_removed": "supprimé",
    "summary_excluded": "exclu",
    "summary_saved": "économisé",
    "summary_noChanges": "Aucun changement",
    "badge_incompressible": "incompressible",
    "badge_excluded": "exclu",
    "state_removed": "Supprimé",
    "state_excluded": "Exclu",
    "btn_removeExclusion": "Supprimer l'exclusion",
    "btn_restore": "Restaurer",
    "btn_undo": "Annuler",
    "btn_apply": "Appliquer",
    "btn_exclude": "Exclusion",
    "title_exclude": "Exclure définitivement cette image de la compression",
    "title_download": "Télécharger l'image",
    "label_profile": "Profil",
    "title_keepMeta": "Conserver les métadonnées (EXIF, ICC, XMP)",
    "title_shrinkToInline": "Réduire à la résolution intégrée (intégré/citation uniquement)",
    "title_keepDimension": "Conserver la taille d'affichage en HTML",
    "btn_showExcluded": "Afficher l'exclusion ($1)",
    "loading_showingExclusions": "Affichage des exclusions...",
    "progress_done": "Terminé",
    "loading_compressing": "Compression de $1...",
    "loading_restoring": "Restauration de $1...",
    "alert_errorAt": "Erreur sur $1 : $2",
    "text_unknown": "Inconnu",
    "error_noComposeWindow": "Aucune fenêtre de rédaction ouverte.",
    "loading_preparingSend": "Préparation de l'envoi...",
    "error_prefix": "Erreur : $1"
}


# ── Italienisch ──────────────────────────────────────────────

IT_OVERRIDES = {
    "extensionDescription": "Compressione immagini all'avanguardia con JPEGli, PNGquant e OxiPNG.",
    "options_general": "Generale",
    "sendMode_ask": "Ricorda elementi non elaborati prima dell'invio",
    "sendMode_auto": "Esegui tutte le azioni senza conferma prima dell'invio",
    "sendMode_manual": "Gestisco tutto manualmente tramite il pulsante nella finestra di composizione",
    "label_minFileSize": "Dim. min. file (KB):",
    "label_minSavingsPercent": "Risparmio min. (%):",
    "label_replaceText": "Testo sostitutivo per immagini di citazione rimosse:",
    "options_attachments": "Immagini negli allegati",
    "options_inline": "Immagini inline",
    "options_quotes": "Immagini nelle citazioni",
    "label_compressionProfile": "Profilo di compressione:",
    "options_editProfile": "Modifica profilo di compressione",
    "btn_delete": "Elimina",
    "label_preserveMeta": "Conserva metadati (EXIF, ICC, XMP)",
    "label_crossConvert": "Consenti conversione incrociata (PNG ↔ JPG) se risparmia spazio",
    "label_antialiasing": "Antialiasing (fattore 1.0–2.0):",
    "label_scaleToDisplay": "Ridimensiona immagini grandi alla dimensione di visualizzazione (non si applica agli allegati)",
    "label_resizeAlgorithm": "Algoritmo di ridimensionamento:",
    "label_jpegQuality": "Qualità JPEG:",
    "label_chromaSubsampling": "Sottocampionamento crominanza:",
    "label_maxColors": "Colori max.:",
    "label_minQuality": "Qualità min.:",
    "label_maxQuality": "Qualità max.:",
    "label_dithering": "Dithering:",
    "label_speed": "Velocità (più alto = più veloce):",
    "label_oxipngAlpha": "Ottimizzazione alfa (visivamente senza perdite)",
    "label_optimizationLevel": "Livello di ottimizzazione:",
    "btn_saveAs": "Salva con nome:",
    "label_name": "Nome:",
    "placeholder_templateName": "Nome profilo",
    "btn_exportProfiles": "Esporta profili",
    "btn_importProfiles": "Importa profili",
    "options_exclusions": "Esclusioni permanenti",
    "label_excludedImages": "Immagini escluse:",
    "btn_clearList": "Svuota lista",
    "text_saved": "Salvato",
    "btn_resetToDefault": "Ripristina valori predefiniti",
    "btn_settings": "Impostazioni",
    "popup_behavior": "Comportamento",
    "popup_profiles": "Profili",
    "cat_attachment": "Allegato",
    "cat_inline": "Inline",
    "cat_quote": "Citazione",
    "text_noImagesFound": "Nessuna immagine trovata da comprimere.",
    "btn_applyAll": "Applica tutto",
    "text_processing": "Elaborazione in corso...",
    "confirmSend_title": "Compressione immagini",
    "btn_cancel": "Annulla",
    "btn_send": "Invia",
    "btn_applyAllAndSend": "Applica tutto e invia",
    "loading_imagesLoading": "Caricamento immagini...",
    "col_type": "Tipo",
    "col_size": "Dimensione",
    "col_resolution": "Risoluzione",
    "col_inlineResolution": "Risoluzione inline",
    "col_savings": "Risparmio",
    "summary_compressed": "compresso",
    "summary_removed": "rimosso",
    "summary_excluded": "escluso",
    "summary_saved": "risparmiato",
    "summary_noChanges": "Nessuna modifica",
    "badge_incompressible": "incomprimibile",
    "badge_excluded": "escluso",
    "state_removed": "Rimosso",
    "state_excluded": "Escluso",
    "btn_removeExclusion": "Rimuovi esclusione",
    "btn_restore": "Ripristina",
    "btn_undo": "Annulla",
    "btn_apply": "Applica",
    "btn_exclude": "Eccezione",
    "title_exclude": "Escludi permanentemente questa immagine dalla compressione",
    "title_download": "Scarica immagine",
    "label_profile": "Profilo",
    "title_keepMeta": "Conserva metadati (EXIF, ICC, XMP)",
    "title_shrinkToInline": "Riduci alla risoluzione inline (solo inline/citazione)",
    "title_keepDimension": "Mantieni dimensione di visualizzazione in HTML",
    "btn_showExcluded": "Mostra esclusione ($1)",
    "loading_showingExclusions": "Mostrando esclusioni...",
    "progress_done": "Fatto",
    "loading_compressing": "Compressione di $1...",
    "loading_restoring": "Ripristino di $1...",
    "alert_errorAt": "Errore su $1: $2",
    "text_unknown": "Sconosciuto",
    "error_noComposeWindow": "Nessuna finestra di composizione aperta.",
    "loading_preparingSend": "Preparazione invio...",
    "error_prefix": "Errore: $1"
}


# ── Portugiesisch ────────────────────────────────────────────

PT_OVERRIDES = {
    "extensionDescription": "Compressão de imagem topo de gama com JPEGli, PNGquant e OxiPNG.",
    "options_general": "Geral",
    "sendMode_ask": "Lembrar itens não processados antes de enviar",
    "sendMode_auto": "Executar todas as ações sem confirmação antes de enviar",
    "sendMode_manual": "Trato de tudo manualmente através do botão na janela de composição",
    "label_minFileSize": "Tamanho mín. ficheiro (KB):",
    "label_minSavingsPercent": "Poupança mín. (%):",
    "label_replaceText": "Texto substituto para imagens de citação removidas:",
    "options_attachments": "Imagens em anexo",
    "options_inline": "Imagens inline",
    "options_quotes": "Imagens em citações",
    "label_compressionProfile": "Perfil de compressão:",
    "options_editProfile": "Editar perfil de compressão",
    "btn_delete": "Eliminar",
    "label_preserveMeta": "Preservar metadados (EXIF, ICC, XMP)",
    "label_crossConvert": "Permitir conversão cruzada (PNG ↔ JPG) se poupar espaço",
    "label_antialiasing": "Antialiasing (fator 1.0–2.0):",
    "label_scaleToDisplay": "Reduzir imagens grandes ao tamanho de exibição (não se aplica a anexos)",
    "label_resizeAlgorithm": "Algoritmo de redimensionamento:",
    "label_jpegQuality": "Qualidade JPEG:",
    "label_chromaSubsampling": "Subamostragem de crominância:",
    "label_maxColors": "Máx. cores:",
    "label_minQuality": "Qualidade mín.:",
    "label_maxQuality": "Qualidade máx.:",
    "label_dithering": "Dithering:",
    "label_speed": "Velocidade (maior = mais rápido):",
    "label_oxipngAlpha": "Otimização alfa (visualmente sem perdas)",
    "label_optimizationLevel": "Nível de otimização:",
    "btn_saveAs": "Guardar como:",
    "label_name": "Nome:",
    "placeholder_templateName": "Nome do perfil",
    "btn_exportProfiles": "Exportar perfis",
    "btn_importProfiles": "Importar perfis",
    "options_exclusions": "Exclusões permanentes",
    "label_excludedImages": "Imagens excluídas:",
    "btn_clearList": "Limpar lista",
    "text_saved": "Guardado",
    "btn_resetToDefault": "Restaurar predefinições",
    "btn_settings": "Definições",
    "popup_behavior": "Comportamento",
    "popup_profiles": "Perfis",
    "cat_attachment": "Anexo",
    "cat_inline": "Inline",
    "cat_quote": "Citação",
    "text_noImagesFound": "Nenhuma imagem encontrada para comprimir.",
    "btn_applyAll": "Aplicar tudo",
    "text_processing": "A processar...",
    "confirmSend_title": "Compressão de imagem",
    "btn_cancel": "Cancelar",
    "btn_send": "Enviar",
    "btn_applyAllAndSend": "Aplicar tudo e enviar",
    "loading_imagesLoading": "A carregar imagens...",
    "col_type": "Tipo",
    "col_size": "Tamanho",
    "col_resolution": "Resolução",
    "col_inlineResolution": "Resolução inline",
    "col_savings": "Poupança",
    "summary_compressed": "comprimido",
    "summary_removed": "removido",
    "summary_excluded": "excluído",
    "summary_saved": "poupado",
    "summary_noChanges": "Sem alterações",
    "badge_incompressible": "incompressível",
    "badge_excluded": "excluído",
    "state_removed": "Removido",
    "state_excluded": "Excluído",
    "btn_removeExclusion": "Remover exclusão",
    "btn_restore": "Restaurar",
    "btn_undo": "Desfazer",
    "btn_apply": "Aplicar",
    "btn_exclude": "Exceção",
    "title_exclude": "Excluir permanentemente esta imagem da compressão",
    "title_download": "Descarregar imagem",
    "label_profile": "Perfil",
    "title_keepMeta": "Preservar metadados (EXIF, ICC, XMP)",
    "title_shrinkToInline": "Reduzir para resolução inline (apenas inline/citação)",
    "title_keepDimension": "Manter tamanho de exibição no HTML",
    "btn_showExcluded": "Mostrar exclusão ($1)",
    "loading_showingExclusions": "A mostrar exclusões...",
    "progress_done": "Concluído",
    "loading_compressing": "A comprimir $1...",
    "loading_restoring": "A restaurar $1...",
    "alert_errorAt": "Erro em $1: $2",
    "text_unknown": "Desconhecido",
    "error_noComposeWindow": "Nenhuma janela de composição aberta.",
    "loading_preparingSend": "A preparar envio...",
    "error_prefix": "Erro: $1"
}


# ── Russisch ─────────────────────────────────────────────────

RU_OVERRIDES = {
    "extensionDescription": "Современное сжатие изображений с помощью JPEGli, PNGquant и OxiPNG.",
    "options_general": "Общие",
    "sendMode_ask": "Напоминать о невыполненных пунктах перед отправкой",
    "sendMode_auto": "Выполнять все действия без подтверждения перед отправкой",
    "sendMode_manual": "Я всё делаю вручную через кнопку в окне составления",
    "label_minFileSize": "Мин. размер файла (КБ):",
    "label_minSavingsPercent": "Мин. экономия (%):",
    "label_replaceText": "Текст замены для удалённых изображений цитат:",
    "options_attachments": "Изображения во вложениях",
    "options_inline": "Встроенные изображения",
    "options_quotes": "Изображения в цитатах",
    "label_compressionProfile": "Профиль сжатия:",
    "options_editProfile": "Редактировать профиль сжатия",
    "btn_delete": "Удалить",
    "label_preserveMeta": "Сохранять метаданные (EXIF, ICC, XMP)",
    "label_crossConvert": "Разрешить перекрёстную конвертацию (PNG ↔ JPG), если это экономит место",
    "label_antialiasing": "Сглаживание (коэффициент 1.0–2.0):",
    "label_scaleToDisplay": "Уменьшать крупные изображения до размера отображения (не применяется к вложениям)",
    "label_resizeAlgorithm": "Алгоритм изменения размера:",
    "label_jpegQuality": "Качество JPEG:",
    "label_chromaSubsampling": "Субдискретизация цветности:",
    "label_maxColors": "Макс. цветов:",
    "label_minQuality": "Мин. качество:",
    "label_maxQuality": "Макс. качество:",
    "label_dithering": "Дизеринг:",
    "label_speed": "Скорость (выше = быстрее):",
    "label_oxipngAlpha": "Оптимизация альфа-канала (визуально без потерь)",
    "label_optimizationLevel": "Уровень оптимизации:",
    "btn_saveAs": "Сохранить как:",
    "label_name": "Имя:",
    "placeholder_templateName": "Название профиля",
    "btn_exportProfiles": "Экспорт профилей",
    "btn_importProfiles": "Импорт профилей",
    "options_exclusions": "Постоянные исключения",
    "label_excludedImages": "Исключённые изображения:",
    "btn_clearList": "Очистить список",
    "text_saved": "Сохранено",
    "btn_resetToDefault": "Сбросить настройки",
    "btn_settings": "Настройки",
    "popup_behavior": "Поведение",
    "popup_profiles": "Профили",
    "cat_attachment": "Вложение",
    "cat_inline": "Встроенный",
    "cat_quote": "Цитата",
    "text_noImagesFound": "Изображения для сжатия не найдены.",
    "btn_applyAll": "Применить ко всем",
    "text_processing": "Обработка...",
    "confirmSend_title": "Сжатие изображений",
    "btn_cancel": "Отмена",
    "btn_send": "Отправить",
    "btn_applyAllAndSend": "Применить ко всем и отправить",
    "loading_imagesLoading": "Загрузка изображений...",
    "col_type": "Тип",
    "col_size": "Размер",
    "col_resolution": "Разрешение",
    "col_inlineResolution": "Встроенное разрешение",
    "col_savings": "Экономия",
    "summary_compressed": "сжато",
    "summary_removed": "удалено",
    "summary_excluded": "исключено",
    "summary_saved": "сэкономлено",
    "summary_noChanges": "Без изменений",
    "badge_incompressible": "несжимаемо",
    "badge_excluded": "исключено",
    "state_removed": "Удалено",
    "state_excluded": "Исключено",
    "btn_removeExclusion": "Удалить из исключений",
    "btn_restore": "Восстановить",
    "btn_undo": "Отменить",
    "btn_apply": "Применить",
    "btn_exclude": "Исключение",
    "title_exclude": "Постоянно исключить это изображение из сжатия",
    "title_download": "Скачать изображение",
    "label_profile": "Профиль",
    "title_keepMeta": "Сохранять метаданные (EXIF, ICC, XMP)",
    "title_shrinkToInline": "Уменьшить до встроенного разрешения (только встроенные/цитаты)",
    "title_keepDimension": "Сохранять размер отображения в HTML",
    "btn_showExcluded": "Показать исключение ($1)",
    "loading_showingExclusions": "Отображение исключений...",
    "progress_done": "Готово",
    "loading_compressing": "Сжатие $1...",
    "loading_restoring": "Восстановление $1...",
    "alert_errorAt": "Ошибка в $1: $2",
    "text_unknown": "Неизвестно",
    "error_noComposeWindow": "Окно составления не открыто.",
    "loading_preparingSend": "Подготовка к отправке...",
    "error_prefix": "Ошибка: $1"
}


# ── Chinesisch ───────────────────────────────────────────────

ZH_OVERRIDES = {
    "extensionDescription": "使用 JPEGli、PNGquant 和 OxiPNG 进行前沿图像压缩。",
    "options_general": "常规",
    "sendMode_ask": "发送前提醒未处理的项目",
    "sendMode_auto": "发送前自动执行所有操作，无需确认",
    "sendMode_manual": "我通过撰写窗口中的按钮手动处理所有事项",
    "label_minFileSize": "最小文件大小 (KB)：",
    "label_minSavingsPercent": "最小节省 (%)：",
    "label_replaceText": "已删除引用图片的替换文本：",
    "options_attachments": "附件中的图片",
    "options_inline": "内联图片",
    "options_quotes": "引用中的图片",
    "label_compressionProfile": "压缩配置：",
    "options_editProfile": "编辑压缩配置",
    "btn_delete": "删除",
    "label_preserveMeta": "保留元数据 (EXIF, ICC, XMP)",
    "label_crossConvert": "允许交叉转换（PNG ↔ JPG），如果能节省空间",
    "label_antialiasing": "抗锯齿（系数 1.0–2.0）：",
    "label_scaleToDisplay": "将大图片缩小到显示尺寸（不适用于附件）",
    "label_resizeAlgorithm": "缩放算法：",
    "label_jpegQuality": "JPEG 质量：",
    "label_chromaSubsampling": "色度子采样：",
    "label_maxColors": "最大颜色数：",
    "label_minQuality": "最低质量：",
    "label_maxQuality": "最高质量：",
    "label_dithering": "抖动：",
    "label_speed": "速度（越高 = 越快）：",
    "label_oxipngAlpha": "Alpha 优化（视觉无损）",
    "label_optimizationLevel": "优化级别：",
    "btn_saveAs": "另存为：",
    "label_name": "名称：",
    "placeholder_templateName": "配置名称",
    "btn_exportProfiles": "导出配置",
    "btn_importProfiles": "导入配置",
    "options_exclusions": "永久排除",
    "label_excludedImages": "已排除的图片：",
    "btn_clearList": "清空列表",
    "text_saved": "已保存",
    "btn_resetToDefault": "恢复默认设置",
    "btn_settings": "设置",
    "popup_behavior": "行为",
    "popup_profiles": "配置",
    "cat_attachment": "附件",
    "cat_inline": "内联",
    "cat_quote": "引用",
    "text_noImagesFound": "未找到可压缩的图片。",
    "btn_applyAll": "全部应用",
    "text_processing": "正在处理...",
    "confirmSend_title": "图像压缩",
    "btn_cancel": "取消",
    "btn_send": "发送",
    "btn_applyAllAndSend": "全部应用并发送",
    "loading_imagesLoading": "正在加载图片...",
    "col_type": "类型",
    "col_size": "大小",
    "col_resolution": "分辨率",
    "col_inlineResolution": "内联分辨率",
    "col_savings": "节省",
    "summary_compressed": "已压缩",
    "summary_removed": "已删除",
    "summary_excluded": "已排除",
    "summary_saved": "已节省",
    "summary_noChanges": "无更改",
    "badge_incompressible": "不可压缩",
    "badge_excluded": "已排除",
    "state_removed": "已删除",
    "state_excluded": "已排除",
    "btn_removeExclusion": "移除排除",
    "btn_restore": "恢复",
    "btn_undo": "撤销",
    "btn_apply": "应用",
    "btn_exclude": "排除",
    "title_exclude": "从压缩中永久排除此图片",
    "title_download": "下载图片",
    "label_profile": "配置",
    "title_keepMeta": "保留元数据 (EXIF, ICC, XMP)",
    "title_shrinkToInline": "缩小到内联分辨率（仅限内联/引用）",
    "title_keepDimension": "在 HTML 中保持显示尺寸",
    "btn_showExcluded": "显示排除项 ($1)",
    "loading_showingExclusions": "正在显示排除项...",
    "progress_done": "完成",
    "loading_compressing": "正在压缩 $1...",
    "loading_restoring": "正在恢复 $1...",
    "alert_errorAt": "$1 出错: $2",
    "text_unknown": "未知",
    "error_noComposeWindow": "未打开撰写窗口。",
    "loading_preparingSend": "正在准备发送...",
    "error_prefix": "错误: $1"
}


# ── Japanisch ────────────────────────────────────────────────

JA_OVERRIDES = {
    "extensionDescription": "JPEGli、PNGquant、OxiPNGによる最先端の画像圧縮。",
    "options_general": "一般",
    "sendMode_ask": "送信前に未処理の項目を通知する",
    "sendMode_auto": "送信前に確認なしで全ての操作を実行する",
    "sendMode_manual": "作成ウィンドウのボタンで手動で全て処理する",
    "label_minFileSize": "最小ファイルサイズ (KB)：",
    "label_minSavingsPercent": "最小削減率 (%)：",
    "label_replaceText": "削除された引用画像の置換テキスト：",
    "options_attachments": "添付ファイルの画像",
    "options_inline": "インライン画像",
    "options_quotes": "引用内の画像",
    "label_compressionProfile": "圧縮プロファイル：",
    "options_editProfile": "圧縮プロファイルを編集",
    "btn_delete": "削除",
    "label_preserveMeta": "メタデータを保持 (EXIF, ICC, XMP)",
    "label_crossConvert": "容量が削減できる場合は相互変換（PNG ↔ JPG）を許可",
    "label_antialiasing": "アンチエイリアス（係数 1.0–2.0）：",
    "label_scaleToDisplay": "大きな画像を表示サイズに縮小する（添付ファイルには適用されません）",
    "label_resizeAlgorithm": "リサイズアルゴリズム：",
    "label_jpegQuality": "JPEG品質：",
    "label_chromaSubsampling": "クロマサブサンプリング：",
    "label_maxColors": "最大色数：",
    "label_minQuality": "最低品質：",
    "label_maxQuality": "最高品質：",
    "label_dithering": "ディザリング：",
    "label_speed": "速度（高い = 速い）：",
    "label_oxipngAlpha": "Alpha最適化（視覚的に無劣化）",
    "label_optimizationLevel": "最適化レベル：",
    "btn_saveAs": "名前を付けて保存：",
    "label_name": "名前：",
    "placeholder_templateName": "プロファイル名",
    "btn_exportProfiles": "プロファイルをエクスポート",
    "btn_importProfiles": "プロファイルをインポート",
    "options_exclusions": "恒久的な除外",
    "label_excludedImages": "除外された画像：",
    "btn_clearList": "リストを消去",
    "text_saved": "保存しました",
    "btn_resetToDefault": "デフォルトに戻す",
    "btn_settings": "設定",
    "popup_behavior": "動作",
    "popup_profiles": "プロファイル",
    "cat_attachment": "添付ファイル",
    "cat_inline": "インライン",
    "cat_quote": "引用",
    "text_noImagesFound": "圧縮する画像が見つかりません。",
    "btn_applyAll": "すべて適用",
    "text_processing": "処理中...",
    "confirmSend_title": "画像圧縮",
    "btn_cancel": "キャンセル",
    "btn_send": "送信",
    "btn_applyAllAndSend": "すべて適用して送信",
    "loading_imagesLoading": "画像を読み込み中...",
    "col_type": "タイプ",
    "col_size": "サイズ",
    "col_resolution": "解像度",
    "col_inlineResolution": "インライン解像度",
    "col_savings": "削減量",
    "summary_compressed": "圧縮済み",
    "summary_removed": "削除済み",
    "summary_excluded": "除外済み",
    "summary_saved": "削減済み",
    "summary_noChanges": "変更なし",
    "badge_incompressible": "非圧縮性",
    "badge_excluded": "除外済み",
    "state_removed": "削除済み",
    "state_excluded": "除外済み",
    "btn_removeExclusion": "除外を解除",
    "btn_restore": "元に戻す",
    "btn_undo": "元に戻す",
    "btn_apply": "適用",
    "btn_exclude": "除外",
    "title_exclude": "この画像を圧縮から恒久的に除外",
    "title_download": "画像をダウンロード",
    "label_profile": "プロファイル",
    "title_keepMeta": "メタデータを保持 (EXIF, ICC, XMP)",
    "title_shrinkToInline": "インライン解像度に縮小（インライン/引用のみ）",
    "title_keepDimension": "HTMLの表示サイズを維持",
    "btn_showExcluded": "除外を表示 ($1)",
    "loading_showingExclusions": "除外を表示中...",
    "progress_done": "完了",
    "loading_compressing": "$1 を圧縮中...",
    "loading_restoring": "$1 を復元中...",
    "alert_errorAt": "$1 でエラー: $2",
    "text_unknown": "不明",
    "error_noComposeWindow": "作成ウィンドウが開いていません。",
    "loading_preparingSend": "送信を準備中...",
    "error_prefix": "エラー: $1"
}


# ── 26 weitere Sprachen (Englisch als Basis) ─────────────────

EN_BASED_LANGS = [
    "nl",  # Niederländisch
    "pl",  # Polnisch
    "sv",  # Schwedisch
    "tr",  # Türkisch
    "ar",  # Arabisch
    "hi",  # Hindi
    "vi",  # Vietnamesisch
    "th",  # Thailändisch
    "ko",  # Koreanisch
    "id",  # Indonesisch
    "uk",  # Ukrainisch
    "cs",  # Tschechisch
    "el",  # Griechisch
    "he",  # Hebräisch
    "fi",  # Finnisch
    "da",  # Dänisch
    "no",  # Norwegisch
    "hu",  # Ungarisch
    "ro",  # Rumänisch
    "sk",  # Slowakisch
    "bg",  # Bulgarisch
    "hr",  # Kroatisch
    "sl",  # Slowenisch
    "lt",  # Litauisch
    "lv",  # Lettisch
    "et",  # Estnisch
]


# ── Alle Locales zusammenstellen ─────────────────────────────

DE_LOCALE = DE
EN_LOCALE = make_locale(DE_LOCALE, EN_OVERRIDES)

LOCALES = {
    "de": DE_LOCALE,
    "en": EN_LOCALE,
    "es": make_locale(EN_LOCALE, ES_OVERRIDES),
    "fr": make_locale(EN_LOCALE, FR_OVERRIDES),
    "it": make_locale(EN_LOCALE, IT_OVERRIDES),
    "pt": make_locale(EN_LOCALE, PT_OVERRIDES),
    "ru": make_locale(EN_LOCALE, RU_OVERRIDES),
    "zh": make_locale(EN_LOCALE, ZH_OVERRIDES),
    "ja": make_locale(EN_LOCALE, JA_OVERRIDES),
}

for lang in EN_BASED_LANGS:
    LOCALES[lang] = EN_LOCALE


def main():
    output_dir = sys.argv[1] if len(sys.argv) > 1 else "."
    base = os.path.join(output_dir, "_locales")

    for lang, messages in LOCALES.items():
        locale_dir = os.path.join(base, lang)
        os.makedirs(locale_dir, exist_ok=True)
        filepath = os.path.join(locale_dir, "messages.json")
        with open(filepath, "w", encoding="utf-8") as f:
            json.dump(messages, f, ensure_ascii=False, indent=2)
        print(f"  {lang}: {filepath} ({len(messages)} Einträge)")

    print(f"\nFertig: {len(LOCALES)} Sprachen in {base}/")


if __name__ == "__main__":
    main()