Skip to content

Commit c0ac29c

Browse files
committed
fix: remove unnessary config item
1 parent b6ee6f9 commit c0ac29c

File tree

4 files changed

+4
-16
lines changed

4 files changed

+4
-16
lines changed

config.example.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ server:
1111
bind: "127.0.0.1:8080" # Internal binding address
1212

1313
i18n:
14-
default_locale: "en"
15-
available_locales:
16-
- "en"
17-
- "zh-TW"
18-
14+
default_locale: "en" # Available locales: en, zh-TW
15+
1916
guilds:
2017
allowed:
2118
- id: "123456789012345678"

src/http_server.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ mod tests {
187187
},
188188
i18n: I18nConfig {
189189
default_locale: "en".to_string(),
190-
available_locales: vec!["en".to_string()],
191190
},
192191
guilds: GuildConfig { allowed: vec![] },
193192
});

src/utils/config.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ pub struct Config {
1414
#[derive(Debug, Clone, Serialize, Deserialize)]
1515
pub struct I18nConfig {
1616
pub default_locale: String,
17-
pub available_locales: Vec<String>,
1817
}
1918

2019
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -69,10 +68,8 @@ impl Config {
6968
let config: Config = serde_yaml::from_str(&content)?;
7069

7170
// Validate locales
72-
for locale in &config.i18n.available_locales {
73-
if !AVAILABLE_LOCALES.contains(&locale.as_str()) {
74-
return Err(format!("Unsupported locale: {}", locale).into());
75-
}
71+
if !AVAILABLE_LOCALES.contains(&config.i18n.default_locale.as_str()) {
72+
return Err(format!("Unsupported locale: {}", config.i18n.default_locale).into());
7673
}
7774

7875
Ok(config)
@@ -111,7 +108,6 @@ mod tests {
111108
},
112109
i18n: I18nConfig {
113110
default_locale: "en".to_string(),
114-
available_locales: vec!["en".to_string(), "zh-TW".to_string()],
115111
},
116112
guilds: GuildConfig { allowed: vec![] },
117113
};
@@ -142,7 +138,6 @@ mod tests {
142138
let config = Config {
143139
i18n: I18nConfig {
144140
default_locale: "invalid".to_string(),
145-
available_locales: vec!["invalid".to_string()],
146141
},
147142
..create_test_config().1
148143
};
@@ -221,7 +216,5 @@ mod tests {
221216
assert_eq!(config.bot.default_min_member_age, 5184000);
222217

223218
assert_eq!(config.i18n.default_locale, "en");
224-
assert!(config.i18n.available_locales.contains(&"en".to_string()));
225-
assert!(config.i18n.available_locales.contains(&"zh-TW".to_string()));
226219
}
227220
}

src/utils/test_helpers.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ impl TestContext {
2424
},
2525
i18n: crate::utils::config::I18nConfig {
2626
default_locale: "en".to_string(),
27-
available_locales: vec!["en".to_string()],
2827
},
2928
guilds: crate::utils::config::GuildConfig { allowed: vec![] },
3029
};

0 commit comments

Comments
 (0)