Skip to content
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

WIP proof of concept to add localization using fluent-rs #546

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tyiu
Copy link

@tyiu tyiu commented Dec 5, 2024

Do not merge. I'm new to Rust, and I'm opening this proof of concept PR to solicit feedback to ensure that I'm doing the right thing before I make changes for real.

Screenshot 2024-12-05 at 7 27 23 AM

let mut errors = vec![];
let msg = bundle.get_message("universe-title").expect("Message exists");
let pattern = msg.value().expect("Message has a value");
let value: &'static mut str = bundle.format_pattern(pattern, None, &mut errors).to_string().leak();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This leak intuitively seems wrong to me, but I couldn't get passed compilation errors without it. title in ColumnOptionData is static and I didn't know how to get the string from the fluent library there in any other way. Looking for feedback here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we just need to cache the bundle in our app state and fix some of these string lifetimes and we should be good to go. I'll take a pass at it. thanks for getting this started

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants