pub struct ExtraCallerConfig {
pub caller_name: String,
pub import_sources: Vec<String>,
pub namespace_arg_index: Option<usize>,
pub fixed_namespace: Option<String>,
pub namespace_option: Option<NamespaceOptionConfig>,
pub static_replacement: String,
pub dynamic_replacement: String,
}Expand description
Descriptor for a compat-adapter caller that the SWC plugin should recognise
and rewrite in the same way as the native useIntlayer / getIntlayer
calls (i.e. replace the string-key argument with a pre-imported dictionary
object and swap the function name for a *Dictionary variant).
These are supplied entirely by the compat adapter plugins (e.g.
createNextI18nPlugin) and are forwarded into the SWC config; no compat
names are hard-coded inside this crate. The wire format is produced by
toSwcExtraCallers in @intlayer/config/callers — both sides must stay
in sync.
Exactly one of namespace_arg_index, fixed_namespace or
namespace_option describes where the namespace (dictionary key) is read
from; they are tried in that order.
Fields§
§caller_name: StringThe function name the user calls, e.g. "useTranslation".
import_sources: Vec<String>The import package specifiers that can export this function,
e.g. ["react-i18next", "@intlayer/react-i18next"].
namespace_arg_index: Option<usize>Zero-based index of the positional argument that holds the namespace
(dictionary key) string, e.g. 0 for useTranslation('about').
fixed_namespace: Option<String>Compile-time constant namespace — every call site reads the same
dictionary; the dictionary ident is inserted as a new first argument
(lingui’s useLingui() → useDictionary(_messages)).
namespace_option: Option<NamespaceOptionConfig>Namespace read from a property of an options-object argument; the dictionary ident is inserted as a new first argument and the property is rewritten to the key-prefix remainder (or removed).
static_replacement: StringName of the replacement function for static-import mode,
e.g. "useTranslationDictionary".
dynamic_replacement: StringName of the replacement function for dynamic/fetch import mode,
e.g. "useTranslationDictionaryDynamic".
Trait Implementations§
Source§impl Clone for ExtraCallerConfig
impl Clone for ExtraCallerConfig
Source§impl Debug for ExtraCallerConfig
impl Debug for ExtraCallerConfig
Source§impl<'de> Deserialize<'de> for ExtraCallerConfig
impl<'de> Deserialize<'de> for ExtraCallerConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ExtraCallerConfig
impl RefUnwindSafe for ExtraCallerConfig
impl Send for ExtraCallerConfig
impl Sync for ExtraCallerConfig
impl Unpin for ExtraCallerConfig
impl UnsafeUnpin for ExtraCallerConfig
impl UnwindSafe for ExtraCallerConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more