From bc6783327c5a84856ffd57fe937ceeed95dc7f14 Mon Sep 17 00:00:00 2001 From: Alessandro Castellani Date: Mon, 30 Sep 2024 12:52:41 +0300 Subject: [PATCH] Bug 1921537 - Use fluent-ffi to properly adapt Rust fluent bundle to gecko. r=mkmelin Differential Revision: https://phabricator.services.mozilla.com/D224007 --HG-- extra : amend_source : a7cf94a46be2073cbee4bfdc8c20a6ecda4da904 --- rust/Cargo.lock | 1 + rust/sys_tray/Cargo.toml | 1 + rust/sys_tray/src/linux/mod.rs | 9 ++++++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 964485b90f..85b7fe7524 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -5143,6 +5143,7 @@ version = "0.1.0" dependencies = [ "cstr", "fluent", + "fluent-ffi", "ksni", "log", "moz_task", diff --git a/rust/sys_tray/Cargo.toml b/rust/sys_tray/Cargo.toml index d5071486df..29656e3018 100644 --- a/rust/sys_tray/Cargo.toml +++ b/rust/sys_tray/Cargo.toml @@ -14,6 +14,7 @@ nsstring = { path = "../../../xpcom/rust/nsstring" } thin-vec = "0.2" unic-langid = "0.9" xpcom = { path = "../../../xpcom/rust/xpcom" } +fluent-ffi = { path = "../../../intl/l10n/rust/fluent-ffi" } [target.'cfg(all(target_os = "linux", target_arch = "x86_64"))'.dependencies] ksni = "0.2.2" diff --git a/rust/sys_tray/src/linux/mod.rs b/rust/sys_tray/src/linux/mod.rs index cf108b1e07..19aa9d7f1a 100644 --- a/rust/sys_tray/src/linux/mod.rs +++ b/rust/sys_tray/src/linux/mod.rs @@ -2,10 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use fluent::FluentBundle; +use fluent_ffi::{adapt_bundle_for_gecko, FluentBundleRc}; use ksni::Handle; use nserror::{nsresult, NS_OK}; use std::os::raw::c_void; +use std::rc::Rc; use system_tray::{SystemTray, TrayItem, XdgIcon}; use xpcom::{nsIID, xpcom_method, RefPtr}; @@ -41,9 +42,11 @@ impl LinuxSysTrayHandler { pub fn new() -> RefPtr { let locs = locales::app_locales().expect("Failed to retrieve application locales"); let resource = locales::fl_resource().expect("Failed to parse fluent templates"); - let mut bundle = FluentBundle::new(locs); + let mut bundle = FluentBundleRc::new(locs); + adapt_bundle_for_gecko(&mut bundle, None); + bundle - .add_resource(resource) + .add_resource(Rc::new(resource)) .expect("Failed to add resources to bundle"); // Grab the quit message