1- use crate :: error:: TranslateError ;
1+ use crate :: error:: { TranslateError , TranslateErrorKind } ;
22use crate :: snippet:: Style ;
33use crate :: { DiagnosticArg , DiagnosticMessage , FluentBundle } ;
44use rustc_data_structures:: sync:: Lrc ;
@@ -95,6 +95,16 @@ pub trait Translate {
9595 // The primary bundle was present and translation succeeded
9696 Some ( Ok ( t) ) => t,
9797
98+ // If `translate_with_bundle` returns `Err` with the primary bundle, this is likely
99+ // just that the primary bundle doesn't contain the message being translated, so
100+ // proceed to the fallback bundle.
101+ Some ( Err (
102+ primary @ TranslateError :: One {
103+ kind : TranslateErrorKind :: MessageMissing , ..
104+ } ,
105+ ) ) => translate_with_bundle ( self . fallback_fluent_bundle ( ) )
106+ . map_err ( |fallback| primary. and ( fallback) ) ?,
107+
98108 // Always yeet out for errors on debug (unless
99109 // `RUSTC_TRANSLATION_NO_DEBUG_ASSERT` is set in the environment - this allows
100110 // local runs of the test suites, of builds with debug assertions, to test the
@@ -106,9 +116,8 @@ pub trait Translate {
106116 do yeet primary
107117 }
108118
109- // If `translate_with_bundle` returns `Err` with the primary bundle, this is likely
110- // just that the primary bundle doesn't contain the message being translated or
111- // something else went wrong) so proceed to the fallback bundle.
119+ // ..otherwise, for end users, an error about this wouldn't be useful or actionable, so
120+ // just hide it and try with the fallback bundle.
112121 Some ( Err ( primary) ) => translate_with_bundle ( self . fallback_fluent_bundle ( ) )
113122 . map_err ( |fallback| primary. and ( fallback) ) ?,
114123
0 commit comments