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

Add C interface #211

Open
cireu opened this issue Dec 28, 2020 · 6 comments
Open

Add C interface #211

cireu opened this issue Dec 28, 2020 · 6 comments
Labels
design-decision Issues pending design decision, usually Rust specific enhancement help wanted We need help making decisions or writing PRs for this.

Comments

@cireu
Copy link

cireu commented Dec 28, 2020

Fluent is a wonderful project for localization.

Somebody is talking about use fluent to power the localization of Emacs. Emacs is written in C and Elisp, a C interface of Fluent can help us to reuse fluent-rs and we don't need to reinvent wheels like fluent-c.

As Stallman says(https://lists.gnu.org/archive/html/emacs-devel/2020-12/msg01875.html), a C interface can also help a lot of GNU project to use fluent(instead of gettext) to power their localization. Would you like to provide a set of C interfaces?

@Pike
Copy link
Contributor

Pike commented Dec 28, 2020

I've dug into that thread a bit, and can't say that I'm fully understanding all the context yet.

To the question, I think this is an ask for localization-level API, and I guess Zibi's still finding out more stuff about that as he's working on converting the full Fluent stack in Firefox to Rust. We should probably wait for that to succeed before thinking about C APIs. Firefox talks to Fluent through FFI, and the code we currently ship has parts in JavaScript still.

Whether that implementation would be good for the FSF is also a question about licensing. Fluent-rs is APL/MIT, and while APL is usable from GPLv3 code. I haven't found indications on whether that's a problem for adoption or not.

I'd also add that the folks that are or used to be involved in Fluent are no C folks, and couldn't advice on how to map concepts to C (and in particular GNU) best practices. This would likely require a collaborative effort between folks knowing fluent-rs and potential consumers of the API on the C level.

@zbraniecki
Copy link
Collaborator

Hi! Thanks for reaching out!

We do use fluent-rs in Gecko via C FFI. Here's the relevant file - https://searchfox.org/mozilla-central/source/intl/l10n/rust/fluent-ffi/src/bundle.rs#67

It's not yet super trivial to package it and, as Axel said, I'm currently working on a "higher level" API for Fluent that wraps around FluentBundle to provide more complete experience of fallbacking and manage resource loading.

Since e use Fluent via C FFI in Gecko, I believe our experience may be of help here, and I'd be happy to work with you on extracting the bits of fluent-ffi out of Gecko and into a standalone crate for you to use.

Would that help?

@cireu
Copy link
Author

cireu commented Dec 29, 2020

Thanks!

I think I can model an POC demo after Zibi's code to help people in emacs-devel see the power of Fluent.

I'm also waiting for your good news about fluent-bundle ;)

@zbraniecki
Copy link
Collaborator

fluent-bundle is quite stable. I'm waiting with 1.0 release till I validate higher level in production, but so far it looks like the API holds well.

The higher level (fluent-fallback and some resource and lifecycle managment) are more in flux. I'm looking into stabilizing them to a more pre 1.0 level over the next month or two.

@gregtatum
Copy link
Member

fluent-rs is already validated on Firefox as we've been using it in our release population. We haven't discussed officially bumping to 1.0 here. On the Firefox side the FFI hooks into ICU4C for some of the date time and number format operations. It seems like a C FFI should have these integrated as well.

I'd like to file an issue for hooking into ICU4X for the examples here, and then from there it would be possible to put together a C API I think.

ICU4X is using Diplomat for its FFI, but there is also uniffi which seems to have some nice ergonomics. It could be possible to put together the C APIs this way.

@gregtatum gregtatum added help wanted We need help making decisions or writing PRs for this. design-decision Issues pending design decision, usually Rust specific enhancement labels Nov 7, 2022
@gregtatum
Copy link
Member

This does seem in scope, but is probably a large undertaking for a contributor to take on. Mozilla doesn't have a specific need for this feature at this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design-decision Issues pending design decision, usually Rust specific enhancement help wanted We need help making decisions or writing PRs for this.
Projects
None yet
Development

No branches or pull requests

4 participants