The previous approach built tooltip strings by formatting a translated
category name (e.g. "Month") into a generic "Previous %1$s" template.
This is a classic gettext concatenation anti-pattern: languages with
grammatical gender (French, Spanish, German, …) need the adjective to
agree with the noun, and word order can differ from English, so
translators of the format string have no way to produce a correct
result.
Replace the format strings and their helper callbacks with two explicit
GObject properties on GcalMultiChoice: prev-button-tooltip-text and
next-button-tooltip-text. The buttons in the template now bind to
these properties directly. Each widget instance in gcal-date-chooser.blp
sets its own fully self-contained translatable string ("Previous month",
"Next month", "Previous year", "Next year"), giving translators all the
context they need to handle gender and word order correctly.
Closes: https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/1547
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/721>
112 lines
3.0 KiB
Plaintext
112 lines
3.0 KiB
Plaintext
using Gtk 4.0;
|
||
using Adw 1;
|
||
|
||
template $GcalDateChooser: Adw.Bin {
|
||
Grid {
|
||
orientation: vertical;
|
||
|
||
$GcalMultiChoice month_choice {
|
||
halign: fill;
|
||
min-value: 0;
|
||
max-value: 11;
|
||
animate: false;
|
||
value: 0;
|
||
wrap: true;
|
||
category: _("Month");
|
||
previous-button-tooltip: _("Previous Month");
|
||
next-button-tooltip: _("Next Month");
|
||
visible: bind $get_split_choice_visible(template.show-heading, template.split-month-year) as <bool>;
|
||
notify::value => $split_multi_choice_changed() swapped;
|
||
|
||
layout {
|
||
column: 0;
|
||
row: 0;
|
||
}
|
||
}
|
||
|
||
$GcalMultiChoice year_choice {
|
||
visible: bind $get_split_choice_visible(template.show-heading, template.split-month-year) as <bool>;
|
||
halign: fill;
|
||
min-value: 1;
|
||
max-value: 9999;
|
||
animate: false;
|
||
value: 0;
|
||
category: _("Year");
|
||
previous-button-tooltip: _("Previous Year");
|
||
next-button-tooltip: _("Next Year");
|
||
notify::value => $split_multi_choice_changed() swapped;
|
||
|
||
layout {
|
||
column: 1;
|
||
row: 0;
|
||
}
|
||
}
|
||
|
||
$GcalMultiChoice combined_choice {
|
||
visible: bind $get_combined_choice_visible(template.show-heading, template.split-month-year) as <bool>;
|
||
halign: fill;
|
||
// From January 1st, 1 (32 * (1 * 12 + 0) + 0):
|
||
min-value: 384;
|
||
// …to December 31st, 9999 (32 * (9999×12+11) + 30):
|
||
max-value: 3839998;
|
||
popover: popover;
|
||
animate: false;
|
||
value: 0;
|
||
category: _("Month");
|
||
previous-button-tooltip: _("Previous Month");
|
||
next-button-tooltip: _("Next Month");
|
||
notify::value => $combined_multi_choice_changed() swapped;
|
||
|
||
layout {
|
||
column: 0;
|
||
column-span: 2;
|
||
row: 0;
|
||
}
|
||
}
|
||
|
||
Grid grid {
|
||
row-homogeneous: true;
|
||
column-homogeneous: true;
|
||
|
||
layout {
|
||
column: 0;
|
||
column-span: 2;
|
||
row: 1;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
Popover popover {
|
||
Box {
|
||
orientation: vertical;
|
||
spacing: 12;
|
||
|
||
$GcalMultiChoice popover_month_choice {
|
||
wrap: true;
|
||
min-value: bind month_choice.min-value bidirectional;
|
||
max-value: bind month_choice.max-value bidirectional;
|
||
animate: bind month_choice.animate bidirectional;
|
||
value: bind month_choice.value bidirectional;
|
||
category: bind month_choice.category bidirectional;
|
||
previous-button-tooltip: bind month_choice.previous-button-tooltip;
|
||
next-button-tooltip: bind month_choice.next-button-tooltip;
|
||
}
|
||
|
||
$GcalMultiChoice {
|
||
min-value: bind year_choice.min-value bidirectional;
|
||
max-value: bind year_choice.max-value bidirectional;
|
||
animate: bind year_choice.animate bidirectional;
|
||
value: bind year_choice.value bidirectional;
|
||
category: bind year_choice.category bidirectional;
|
||
previous-button-tooltip: bind year_choice.previous-button-tooltip;
|
||
next-button-tooltip: bind year_choice.next-button-tooltip;
|
||
}
|
||
|
||
styles [
|
||
"activatable",
|
||
"month",
|
||
]
|
||
}
|
||
}
|