-
Notifications
You must be signed in to change notification settings - Fork 98
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
Add transform to FluentBundle #131
Conversation
This is just the scaffolding. I will later add more features from https://searchfox.org/mozilla-central/source/intl/l10n/L10nRegistry.jsm#494 like elongating, wrapping etc. For now, I added the @Manishearth - can you verify that I'm using Rust well here? I'd love to use type/trait alias for |
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.
This seems like a good design. Yeah, there's no nice way to do trait aliases right now.
fluent-bundle/src/bundle.rs
Outdated
@@ -238,6 +240,17 @@ impl<R> FluentBundle<R> { | |||
self.use_isolating = value; | |||
} | |||
|
|||
pub fn set_transform<F>(&mut self, func: Option<F>) | |||
where | |||
F: 'static + Fn(&str) -> String + Send + Sync |
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.
usually you write 'static
at the end
fluent-bundle/src/bundle.rs
Outdated
where | ||
F: for<'a> Fn(&[FluentValue<'a>], &FluentArgs) -> FluentValue<'a> + Sync + Send, | ||
F: 'static + for<'a> Fn(&[FluentValue<'a>], &FluentArgs) -> FluentValue<'a> + Sync + Send, |
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.
F: 'static + for<'a> Fn(&[FluentValue<'a>], &FluentArgs) -> FluentValue<'a> + Sync + Send, | |
F: for<'a> Fn(&[FluentValue<'a>], &FluentArgs) -> FluentValue<'a> + Sync + Send + 'static, |
fluent-bundle/src/bundle.rs
Outdated
@@ -238,6 +240,17 @@ impl<R> FluentBundle<R> { | |||
self.use_isolating = value; | |||
} | |||
|
|||
pub fn set_transform<F>(&mut self, func: Option<F>) | |||
where | |||
F: 'static + Fn(&str) -> Cow<str> + Send + Sync |
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.
F: 'static + Fn(&str) -> Cow<str> + Send + Sync | |
F: Fn(&str) -> Cow<str> + Send + Sync + 'static |
fluent-pseudo/Cargo.toml
Outdated
categories = ["localization", "internationalization"] | ||
|
||
[dependencies] | ||
regex = "1.2" |
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.
newline at eof
Can we implement this in a way that the gecko wrapper can forward transform functions written in js? This would be important for fluent-rs being a drop-in replacement for fluent.js. |
We could try to produce an equivalent of The rust side that this PR provides can be fed with anything so we can explore that |
Fixes #97