@@ -14,12 +14,27 @@ use std::io;
14
14
use std:: path:: Path ;
15
15
use tracing:: { instrument, trace} ;
16
16
17
+ #[ cfg( parallel_compiler) ]
18
+ use intl_memoizer:: concurrent:: IntlLangMemoizer ;
19
+ #[ cfg( not( parallel_compiler) ) ]
20
+ use intl_memoizer:: IntlLangMemoizer ;
21
+
17
22
pub use fluent_bundle:: { FluentArgs , FluentError , FluentValue } ;
18
23
pub use unic_langid:: { langid, LanguageIdentifier } ;
19
24
20
25
static FALLBACK_FLUENT_RESOURCE : & ' static str = include_str ! ( "../locales/en-US/diagnostics.ftl" ) ;
21
26
22
- pub type FluentBundle = fluent_bundle:: FluentBundle < FluentResource > ;
27
+ pub type FluentBundle = fluent_bundle:: bundle:: FluentBundle < FluentResource , IntlLangMemoizer > ;
28
+
29
+ #[ cfg( parallel_compiler) ]
30
+ fn new_bundle ( locales : Vec < LanguageIdentifier > ) -> FluentBundle {
31
+ FluentBundle :: new_concurrent ( locales)
32
+ }
33
+
34
+ #[ cfg( not( parallel_compiler) ) ]
35
+ fn new_bundle ( locales : Vec < LanguageIdentifier > ) -> FluentBundle {
36
+ FluentBundle :: new ( locales)
37
+ }
23
38
24
39
#[ derive( Debug ) ]
25
40
pub enum TranslationBundleError {
@@ -114,7 +129,7 @@ pub fn fluent_bundle(
114
129
// provided locale.
115
130
let locale = requested_locale. clone ( ) . unwrap_or ( fallback_locale) ;
116
131
trace ! ( ?locale) ;
117
- let mut bundle = FluentBundle :: new ( vec ! [ locale] ) ;
132
+ let mut bundle = new_bundle ( vec ! [ locale] ) ;
118
133
119
134
// Fluent diagnostics can insert directionality isolation markers around interpolated variables
120
135
// indicating that there may be a shift from right-to-left to left-to-right text (or
@@ -176,7 +191,7 @@ pub fn fallback_fluent_bundle(
176
191
let fallback_resource = FluentResource :: try_new ( FALLBACK_FLUENT_RESOURCE . to_string ( ) )
177
192
. map_err ( TranslationBundleError :: from) ?;
178
193
trace ! ( ?fallback_resource) ;
179
- let mut fallback_bundle = FluentBundle :: new ( vec ! [ langid!( "en-US" ) ] ) ;
194
+ let mut fallback_bundle = new_bundle ( vec ! [ langid!( "en-US" ) ] ) ;
180
195
// See comment in `fluent_bundle`.
181
196
fallback_bundle. set_use_isolating ( with_directionality_markers) ;
182
197
fallback_bundle. add_resource ( fallback_resource) . map_err ( TranslationBundleError :: from) ?;
0 commit comments