Handle selecting the default locale better

This commit is contained in:
mejrs 2023-02-14 21:26:17 +01:00
parent 6f92031233
commit 242daf86d9

View File

@ -135,7 +135,10 @@ pub fn fluent_bundle(
let fallback_locale = langid!("en-US"); let fallback_locale = langid!("en-US");
let requested_fallback_locale = requested_locale.as_ref() == Some(&fallback_locale); let requested_fallback_locale = requested_locale.as_ref() == Some(&fallback_locale);
trace!(?requested_fallback_locale);
if requested_fallback_locale && additional_ftl_path.is_none() {
return Ok(None);
}
// If there is only `-Z additional-ftl-path`, assume locale is "en-US", otherwise use user // If there is only `-Z additional-ftl-path`, assume locale is "en-US", otherwise use user
// provided locale. // provided locale.
let locale = requested_locale.clone().unwrap_or(fallback_locale); let locale = requested_locale.clone().unwrap_or(fallback_locale);
@ -153,7 +156,7 @@ pub fn fluent_bundle(
bundle.set_use_isolating(with_directionality_markers); bundle.set_use_isolating(with_directionality_markers);
// If the user requests the default locale then don't try to load anything. // If the user requests the default locale then don't try to load anything.
if !requested_fallback_locale && let Some(requested_locale) = requested_locale { if let Some(requested_locale) = requested_locale {
let mut found_resources = false; let mut found_resources = false;
for sysroot in user_provided_sysroot.iter_mut().chain(sysroot_candidates.iter_mut()) { for sysroot in user_provided_sysroot.iter_mut().chain(sysroot_candidates.iter_mut()) {
sysroot.push("share"); sysroot.push("share");