Don't produce isolation marks in fluent

This commit is contained in:
juliancoffee 2022-08-20 13:23:23 +03:00
parent 74e8dbf757
commit 64c909cba0

View File

@ -198,6 +198,11 @@ impl assets::Compound for Language {
} }
} }
// NOTE:
// Basically a hack, but conrod can't use isolation marks yet.
// Veloren Issue 1649
bundle.set_use_isolating(false);
Ok(Self { Ok(Self {
bundle, bundle,
fonts, fonts,
@ -292,12 +297,7 @@ impl LocalizationGuard {
.as_ref() .as_ref()
.and_then(|fb| fb.try_msg(key, Some(args))) .and_then(|fb| fb.try_msg(key, Some(args)))
}) })
.map(|x| { .map(|res| Cow::Owned(res.into_owned()))
// NOTE:
// Hack. Remove Unicode Directionality Marks, conrod doesn't support them.
let res = x.replace('\u{2068}', "").replace('\u{2069}', "");
Cow::Owned(res)
})
} }
/// Get a localized text from the given key using given arguments /// Get a localized text from the given key using given arguments
@ -352,12 +352,6 @@ impl LocalizationGuard {
.as_ref() .as_ref()
.and_then(|fb| fb.try_variation(key, seed, Some(args))) .and_then(|fb| fb.try_variation(key, seed, Some(args)))
}) })
.map(|x| {
// NOTE:
// Hack. Remove Unicode Directionality Marks, conrod doesn't support them.
let res = x.replace('\u{2068}', "").replace('\u{2069}', "");
Cow::Owned(res)
})
} }
/// Get a localized text from the variation of given key with given /// Get a localized text from the variation of given key with given
@ -405,19 +399,11 @@ impl LocalizationGuard {
attr: &str, attr: &str,
args: &'a FluentArgs, args: &'a FluentArgs,
) -> Option<Cow<str>> { ) -> Option<Cow<str>> {
self.active self.active.try_attr(key, attr, Some(args)).or_else(|| {
.try_attr(key, attr, Some(args)) self.fallback
.or_else(|| { .as_ref()
self.fallback .and_then(|fb| fb.try_attr(key, attr, Some(args)))
.as_ref() })
.and_then(|fb| fb.try_attr(key, attr, Some(args)))
})
.map(|x| {
// NOTE:
// Hack. Remove Unicode Directionality Marks, conrod doesn't support them.
let res = x.replace('\u{2068}', "").replace('\u{2069}', "");
Cow::Owned(res)
})
} }
/// Get a localized text from the given key by given attribute and arguments /// Get a localized text from the given key by given attribute and arguments