@@ -14,12 +14,27 @@ use std::io;
1414use std:: path:: Path ;
1515use tracing:: { instrument, trace} ;
1616
17+ #[ cfg( parallel_compiler) ]
18+ use intl_memoizer:: concurrent:: IntlLangMemoizer ;
19+ #[ cfg( not( parallel_compiler) ) ]
20+ use intl_memoizer:: IntlLangMemoizer ;
21+
1722pub use fluent_bundle:: { FluentArgs , FluentError , FluentValue } ;
1823pub use unic_langid:: { langid, LanguageIdentifier } ;
1924
2025static FALLBACK_FLUENT_RESOURCE : & ' static str = include_str ! ( "../locales/en-US/diagnostics.ftl" ) ;
2126
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+ }
2338
2439#[ derive( Debug ) ]
2540pub enum TranslationBundleError {
@@ -114,7 +129,7 @@ pub fn fluent_bundle(
114129 // provided locale.
115130 let locale = requested_locale. clone ( ) . unwrap_or ( fallback_locale) ;
116131 trace ! ( ?locale) ;
117- let mut bundle = FluentBundle :: new ( vec ! [ locale] ) ;
132+ let mut bundle = new_bundle ( vec ! [ locale] ) ;
118133
119134 // Fluent diagnostics can insert directionality isolation markers around interpolated variables
120135 // 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(
176191 let fallback_resource = FluentResource :: try_new ( FALLBACK_FLUENT_RESOURCE . to_string ( ) )
177192 . map_err ( TranslationBundleError :: from) ?;
178193 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" ) ] ) ;
180195 // See comment in `fluent_bundle`.
181196 fallback_bundle. set_use_isolating ( with_directionality_markers) ;
182197 fallback_bundle. add_resource ( fallback_resource) . map_err ( TranslationBundleError :: from) ?;
0 commit comments