fix: PDF-Exporte folgen der Sprache der Oberfläche

`RoutinePdfExporter._text()` hat den Text übersetzt und dann das Original
geschrieben. Seit dem Englisch-Umschalten waren PDFs damit faktisch
durchgehend deutsch, obwohl die Release-Notizen übersetzte Blätter nennen.

- `_text()` schreibt jetzt die Übersetzung.
- Zusammengesetzte Texte übersetzen zuerst die Vorlage und setzen dann ein
  (Untertitel, Notiz im Rink, "+ %d weitere", Saisonvergleich).
- `_draw_note()` übersetzt vor dem Umbruch, sonst passt kein Satz mehr auf
  einen Katalogschlüssel.
- Fehlende Schlüssel ergänzt (u. a. "Kategorie: %s", "%d Abschnitte",
  "Musik: %s", Tabellenköpfe).

Test: `run_export_tests` baut ein PDF auf Englisch und prüft, dass
Tabellenköpfe und der Saisonvergleich übersetzt sind.
This commit is contained in:
torsten 2026-11-13 13:17:09 +01:00
parent bbf9154221
commit 1b6e6d8ede
4 changed files with 130 additions and 12 deletions

View file

@ -799,3 +799,16 @@
"„%s“: %d Features auf einem Fuß, es zählen höchstens %d.","„%s“: %d Features auf einem Fuß, es zählen höchstens %d.","“%s”: %d features on one foot, at most %d count."
"Bei „%s“ zählen höchstens %d Features der Gruppe „%s“.","Bei „%s“ zählen höchstens %d Features der Gruppe „%s“.","In “%s” at most %d features of the group “%s” count."
"Als PDF","Als PDF","As PDF"
"Kategorie: %s","Kategorie: %s","Category: %s"
"%d Abschnitte","%d Abschnitte","%d sections"
"Musik: %s","Musik: %s","Music: %s"
"+ %d weitere","+ %d weitere","+ %d more"
"Abschnitt","Abschnitt","Section"
"Abschnitte","Abschnitte","Sections"
"#","#","#"
"Fehler","Fehler","Error"
"Warnung","Warnung","Warning"
"Hinweis","Hinweis","Note"
"%s — nicht im Katalog","%s — nicht im Katalog","%s — not in the catalog"
"%s — Feature „%s“ in der Ziel-Saison unbekannt","%s — Feature „%s“ in der Ziel-Saison unbekannt","%s — feature “%s” unknown in the target season"
"• %s — in der Ziel-Saison nicht vorhanden","• %s — in der Ziel-Saison nicht vorhanden","• %s — not available in the target season"

1 keys de en
799 „%s“: %d Features auf einem Fuß, es zählen höchstens %d. „%s“: %d Features auf einem Fuß, es zählen höchstens %d. “%s”: %d features on one foot, at most %d count.
800 Bei „%s“ zählen höchstens %d Features der Gruppe „%s“. Bei „%s“ zählen höchstens %d Features der Gruppe „%s“. In “%s” at most %d features of the group “%s” count.
801 Als PDF Als PDF As PDF
802 Kategorie: %s Kategorie: %s Category: %s
803 %d Abschnitte %d Abschnitte %d sections
804 Musik: %s Musik: %s Music: %s
805 + %d weitere + %d weitere + %d more
806 Abschnitt Abschnitt Section
807 Abschnitte Abschnitte Sections
808 # # #
809 Fehler Fehler Error
810 Warnung Warnung Warning
811 Hinweis Hinweis Note
812 %s — nicht im Katalog %s — nicht im Katalog %s — not in the catalog
813 %s — Feature „%s“ in der Ziel-Saison unbekannt %s — Feature „%s“ in der Ziel-Saison unbekannt %s — feature “%s” unknown in the target season
814 • %s — in der Ziel-Saison nicht vorhanden • %s — in der Ziel-Saison nicht vorhanden • %s — not available in the target season

View file

@ -180,7 +180,7 @@ static func _report_blocks(
for change: SeasonUpgradeCheck.Change in missing_category:
blocks.append(
_report_block(
"• %s — in der Ziel-Saison nicht vorhanden" % change.label,
I18n.t("• %s — in der Ziel-Saison nicht vorhanden") % change.label,
10.0,
false,
TEXT_COLOR,
@ -193,7 +193,7 @@ static func _report_blocks(
var sign := "+" if report.value_delta() >= 0.0 else "−"
blocks.append(
_report_block(
"Basiswert %s → %s (%s%s)"
I18n.t("Basiswert %s → %s (%s%s)")
% [
_number(report.base_value_before),
_number(report.base_value_after),
@ -212,7 +212,7 @@ static func _report_blocks(
if not report.issues.is_empty():
blocks.append(
_report_block(
"Befunde bei Prüfung gegen %s" % report.target_season,
I18n.t("Befunde bei Prüfung gegen %s") % report.target_season,
12.0,
true,
TEXT_COLOR,
@ -223,7 +223,7 @@ static func _report_blocks(
for issue: ValidationIssue in report.issues:
blocks.append(
_report_block(
"• %s: %s" % [issue.severity_label(), issue.message],
"• %s: %s" % [I18n.t(issue.severity_label()), issue.message],
9.5,
false,
MUTED_COLOR,
@ -253,9 +253,9 @@ static func _add_report_group(
static func _report_change_text(change: SeasonUpgradeCheck.Change) -> String:
match change.kind:
SeasonUpgradeCheck.KIND_MISSING_CODE:
return "%s — nicht im Katalog" % change.label
return I18n.t("%s — nicht im Katalog") % change.label
SeasonUpgradeCheck.KIND_UNKNOWN_FEATURE:
return "%s — Feature „%s“ in der Ziel-Saison unbekannt" % [
return I18n.t("%s — Feature „%s“ in der Ziel-Saison unbekannt") % [
change.label,
change.before,
]
@ -574,14 +574,14 @@ static func _routine_subtitle(routine: Routine, section_count: int) -> String:
parts.append(I18n.t("Artistic"))
var category := routine.adult_category.strip_edges()
if not category.is_empty():
parts.append("Kategorie: %s" % category.capitalize())
parts.append(I18n.t("Kategorie: %s") % category.capitalize())
var season := routine.season.strip_edges()
if not season.is_empty():
parts.append(I18n.t("Saison %s") % season)
parts.append("%d Abschnitte" % section_count)
parts.append(I18n.t("%d Abschnitte") % section_count)
parts.append(I18n.t("Gesamt %s") % _fmt_clock(routine.get_duration_seconds()))
if routine.has_music():
parts.append("Musik: %s" % routine.music_file)
parts.append(I18n.t("Musik: %s") % routine.music_file)
return " · ".join(parts)
@ -696,7 +696,7 @@ static func _text(
_n(color.b),
_n(x),
_n(_y(top)),
_pdf_literal(text),
_pdf_literal(caption),
]
)
@ -1554,7 +1554,7 @@ static func _draw_timeline_notes(
if entries.size() > visible:
_text(
lines,
"+ %d weitere" % (entries.size() - visible),
I18n.t("+ %d weitere") % (entries.size() - visible),
x,
top + 16.0 + float(visible) * 13.0,
8.5,
@ -1656,7 +1656,7 @@ static func _draw_note(
text: String
) -> void:
_rect(lines, x, top, width, 36.0, ROW_COLOR, RULE_COLOR, 0.5)
var wrapped := _wrap_text(text, 8.0, width - 16.0, 2)
var wrapped := _wrap_text(I18n.t(text), 8.0, width - 16.0, 2)
for index: int in range(wrapped.size()):
_text(
lines,

View file

@ -192,6 +192,25 @@ func _run() -> void:
comparison_text.contains("Basiswert"),
"the comparison PDF sums the base values"
)
# Die PDF-Texte folgen der Sprache der Oberfläche.
AppSettings.apply_locale("en")
var english_pdf := (
RoutinePdfExporter.build(routine).get_string_from_ascii()
)
var english_comparison := (
RoutinePdfExporter.build_season_comparison(comparison_routine, report)
.get_string_from_ascii()
)
AppSettings.apply_locale("de")
_check(
english_pdf.contains("Duration") and english_pdf.contains("Section"),
"PDF table labels follow the interface language"
)
_check(
english_comparison.contains("not in the catalog"),
"the comparison PDF follows the interface language"
)
_check(
pdf_text.contains(" c") or pdf_text.contains(" l"),
"PDF export contains vector path operators"