From 29a2c4b718fbe4df9e4a38a64a9933a958dfc1d1 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 5 Feb 2023 10:00:17 +0100 Subject: [PATCH] gettext.rs: allow translating non-literal strings A following commit will pass global string constants to the gettext macro. This is not ideal because we might accidentally use the constants without gettext (which we should never do). To fix that we might need to define a macro per constant, or use a proc macro which is maybe not worth it. --- fish-rust/src/wutil/gettext.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fish-rust/src/wutil/gettext.rs b/fish-rust/src/wutil/gettext.rs index a2068b2b7..1842d7eca 100644 --- a/fish-rust/src/wutil/gettext.rs +++ b/fish-rust/src/wutil/gettext.rs @@ -15,7 +15,7 @@ pub fn wgettext_impl_do_not_use_directly(text: &[wchar_t]) -> &'static wstr { /// Get a (possibly translated) string from a string literal. /// This returns a &'static wstr. macro_rules! wgettext { - ($string:literal) => { + ($string:expr) => { crate::wutil::gettext::wgettext_impl_do_not_use_directly( crate::wchar_ffi::u32cstr!($string).as_slice_with_nul(), ) @@ -27,7 +27,7 @@ macro_rules! wgettext { /// The result is a WString. macro_rules! wgettext_fmt { ( - $string:literal, // format string + $string:expr, // format string $($args:expr),* // list of expressions $(,)? // optional trailing comma ) => {