pub struct PluginConfig {
pub dictionaries_dir: String,
pub dictionaries_entry_path: String,
pub dynamic_dictionaries_dir: String,
pub fetch_dictionaries_dir: String,
pub import_mode: Option<String>,
pub replace_dictionary_entry: Option<bool>,
pub nesting_dictionary_keys: Vec<String>,
pub files_list: Vec<String>,
pub dictionary_mode_map: Option<BTreeMap<String, String>>,
pub extra_callers: Vec<ExtraCallerConfig>,
pub field_rename_map: BTreeMap<String, FieldRenameMap>,
pub log_level: Option<String>,
}Expand description
Configuration passed to the plugin via SWC transform options or constructed
directly when using crate::process_transform from native Rust.
Fields§
§dictionaries_dir: StringAbsolute path to the directory containing <key>.json compiled dictionaries.
dictionaries_entry_path: StringAbsolute path to the generated dictionaries entry file (e.g. .intlayer/dictionaries.mjs).
dynamic_dictionaries_dir: StringAbsolute path to the directory containing <key>.mjs dynamic dictionary modules.
fetch_dictionaries_dir: StringAbsolute path to the directory containing <key>.mjs fetch/live dictionary modules.
import_mode: Option<String>Global import mode for all dictionaries: "static" (default), "dynamic", or "fetch".
replace_dictionary_entry: Option<bool>When true, the dictionaries entry file is replaced with export default {} and
export const getDictionaries = () => ({}).
nesting_dictionary_keys: Vec<String>Keys of the dictionaries that reference other dictionaries through nest().
For those, the injected static import points at the generated companion
module (<dictionariesDir>/nested/<key>.mjs) instead of the raw JSON.
The companion re-exports the dictionary with its nest targets attached,
so getNesting resolves them from that local reference rather than from
the global registry this plugin empties — and each target lands in the
chunk of the dictionary referencing it.
Dynamic and fetch modes need nothing here: their generated loaders already attach the same targets per locale.
files_list: Vec<String>Allowlist of absolute file paths to transform. When empty, all files are processed.
dictionary_mode_map: Option<BTreeMap<String, String>>Per-dictionary import mode overrides, keyed by dictionary key.
Values are "static", "dynamic", or "fetch".
extra_callers: Vec<ExtraCallerConfig>Extra caller descriptors injected by compat adapter plugins.
Each entry teaches the plugin to recognise a compat-adapter function
(e.g. useTranslation from react-i18next) and rewrite its call site
to a *Dictionary variant that accepts a pre-imported dictionary object
instead of a string key.
field_rename_map: BTreeMap<String, FieldRenameMap>Field-rename tables keyed by dictionary key, produced by the
build.minify pipeline on the JavaScript side.
When a dictionary is listed here, its compiled JSON has already been
rewritten with the short aliases, so every source-code access to its
content must be rewritten to match (content.title → content.a).
Dictionaries whose JSON was left untouched (edge cases, fetch mode,
opaque consumers) are simply absent from the map.
The whole map arrives empty when the visual editor is enabled: renaming
rewrites the content keys the keyPath is built from, and the editor
resolves every edit by keyPath against the unmerged dictionaries.
Purging still happens, so the dictionaries are still smaller.
log_level: Option<String>Verbosity of the plugin’s build-time reporting: "off" (default),
"info", or "debug".
Trait Implementations§
Source§impl Clone for PluginConfig
impl Clone for PluginConfig
Source§impl Debug for PluginConfig
impl Debug for PluginConfig
Source§impl Default for PluginConfig
impl Default for PluginConfig
Source§impl<'de> Deserialize<'de> for PluginConfig
impl<'de> Deserialize<'de> for PluginConfig
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 PluginConfig
impl RefUnwindSafe for PluginConfig
impl Send for PluginConfig
impl Sync for PluginConfig
impl Unpin for PluginConfig
impl UnsafeUnpin for PluginConfig
impl UnwindSafe for PluginConfig
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