-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disabling Isolation Marks in Fluent #46
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -257,6 +257,22 @@ impl FluentLanguageLoader { | |
|
||
(closure)(&mut iter) | ||
} | ||
|
||
/// Set whether the underlying Fluent logic should insert Unicode | ||
/// Directionality Isolation Marks around placeables. | ||
/// | ||
/// See [`fluent::bundle::FluentBundleBase::set_use_isolating`] for more | ||
/// information. | ||
/// | ||
/// **Note:** This function will have no effect if | ||
/// [`LanguageLoader::load_languages`] has not been called first. | ||
/// | ||
/// Default: `true`. | ||
pub fn set_use_isolating(&self, value: bool) { | ||
for bundle in self.language_config.write().language_bundles.as_mut_slice() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rust surprised me here. I'm able to get mutable access to the a nested field several levels down, and yet we're borrowing the parent immutably with And a question with regard to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I guess we need to be careful not to introduce a deadlock if this method will be called within another method that already holds the lock, seems like that's not the case here so it looks good to me. |
||
bundle.bundle.set_use_isolating(value); | ||
} | ||
} | ||
} | ||
|
||
impl LanguageLoader for FluentLanguageLoader { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps we could add a unit/integration test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, perhaps it would sufficient to check the byte lengths of the output strings? I'll add a commit today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess so, or to be more specific you could check if the string contains the expected special characters or not. One test with it enabled, and one without it enabled.