Refactor fxBibTexte function to include fallback for missing keys and add new fxBibStaticFallback function for bilingual support

This commit modifies the `fxBibTexte` function to utilize a new fallback mechanism via `fxBibStaticFallback`, which provides default translations for missing or incorrectly entered keys in both French and English. Additionally, the error handling in the bib view is updated to ensure proper display of messages for unassigned and duplicate bibs. These changes enhance the robustness and user experience of the bib management system.
This commit is contained in:
2026-06-19 11:32:09 -04:00
parent 026473dd59
commit 717f11e3d5

View File

@ -2813,7 +2813,10 @@ function fxBibTexte($clef, $mem_echo = 0, $blnAllowEmptyLabel = false) {
}
}
if ($str === '' || $str === $clef || $str === '*' . $clef . '*') {
$str = $blnAllowEmptyLabel ? '' : $clef;
$str = fxBibStaticFallback($clef);
if ($str === '') {
$str = $blnAllowEmptyLabel ? '' : $clef;
}
}
}
@ -2823,6 +2826,20 @@ function fxBibTexte($clef, $mem_echo = 0, $blnAllowEmptyLabel = false) {
return $str;
}
/** Repli FR/EN si clé bib_v4 absente ou mal saisie en BD. */
function fxBibStaticFallback($clef) {
global $strLangue;
$lng = ($strLangue === 'en') ? 'en' : 'fr';
$tab = [
'bib_v4_view_cancelled' => ['fr' => 'Annulé', 'en' => 'Cancelled'],
'bib_v4_err_gaps' => ['fr' => 'Dossards non assignés :', 'en' => 'Unassigned bibs:'],
'bib_v4_err_dupes' => ['fr' => 'Dossards en double :', 'en' => 'Duplicate bibs:'],
];
return $tab[$clef][$lng] ?? '';
}
/** Libellé « Annulé » dans la vue dossards — repli si clé BD absente ou mal saisie. */
function fxBibViewCancelledLabel($strLangue = 'fr') {
$str = fxBibTexte('bib_v4_view_cancelled', 0);
@ -4825,11 +4842,11 @@ if (!$blnRangeLocked && (
<div class="bib-error text-danger small mb-2" style="<?php echo (!empty($range['liste_trous']) || !empty($range['liste_doublons'])) ? 'display:block;' : 'display:none;'; ?>">
<?php if (!empty($range['liste_trous'])) { ?>
<div><?php fxBibTexteTrad('bib_v4_err_gaps', 0); ?> <?php echo fxBibEsc($range['liste_trous']); ?></div>
<div><?php fxBibTexteTrad('bib_v4_err_gaps', 1); ?> <?php echo fxBibEsc($range['liste_trous']); ?></div>
<?php } ?>
<?php if (!empty($range['liste_doublons'])) { ?>
<div><?php fxBibTexteTrad('bib_v4_err_dupes', 0); ?> <?php echo fxBibEsc($range['liste_doublons']); ?></div>
<div><?php fxBibTexteTrad('bib_v4_err_dupes', 1); ?> <?php echo fxBibEsc($range['liste_doublons']); ?></div>
<?php } ?>
</div>