From 905da8776e6dcad3a9c6cb8526c1bf286f094864 Mon Sep 17 00:00:00 2001 From: litcc Date: Tue, 10 Sep 2024 20:30:15 +0800 Subject: [PATCH] fix: Add parsing of workspace.metadata.i18n --- crates/support/src/config.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/support/src/config.rs b/crates/support/src/config.rs index ce9ba88..30e2f60 100644 --- a/crates/support/src/config.rs +++ b/crates/support/src/config.rs @@ -63,10 +63,21 @@ impl I18nConfig { } pub fn parse(contents: &str) -> io::Result { - if !contents.contains("[i18n]") && !contents.contains("[package.metadata.i18n]") { + let package_metadata = contents.contains("[package.metadata.i18n]"); + let workspace_metadata = contents.contains("[workspace.metadata.i18n]"); + + if !contents.contains("[i18n]") && !package_metadata && !workspace_metadata { return Ok(I18nConfig::default()); } - let contents = contents.replace("[package.metadata.i18n]", "[i18n]"); + + let contents = if package_metadata { + contents.replace("[package.metadata.i18n]", "[i18n]") + } else if workspace_metadata { + contents.replace("[workspace.metadata.i18n]", "[i18n]") + } else { + contents.to_string() + }; + let mut config: MainConfig = toml::from_str(&contents) .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e.to_string()))?;