Skip to content

Commit

Permalink
🐛 Keys should use kebab-case at all.
Browse files Browse the repository at this point in the history
  • Loading branch information
langyo committed Oct 10, 2024
1 parent 53d1adc commit 741c113
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 63 deletions.
41 changes: 22 additions & 19 deletions packages/types/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,29 @@ use yuuka::derive_struct;

use crate::consts::CACHE_DIR;

derive_struct!(pub Config {
portal: {
title_suffix: String,
footer_banner: [{
text: String,
url: Option<String>,
}],
language: String,
timezone: i32,
},
router: {
media_entry_path: String,
limit_referrer_host: Option<Vec<String>>,
},
upload: {
image_size_limit: String,
webp_auto_convert: bool,
use_source_file_name: bool,
derive_struct!(
#[serde(rename_all = "kebab-case")]
pub Config {
portal: {
title_suffix: String,
footer_banner: [{
text: String,
url: Option<String>,
}],
language: String,
timezone: i32,
},
router: {
media_entry_path: String,
limit_referrer_host: Option<Vec<String>>,
},
upload: {
image_size_limit: String,
webp_auto_convert: bool,
use_source_file_name: bool,
}
}
});
);

pub static CONFIG: Lazy<Arc<Mutex<Config>>> = Lazy::new(|| {
let raw = std::fs::read_to_string(CACHE_DIR.clone()).unwrap();
Expand Down
91 changes: 47 additions & 44 deletions packages/types/src/i18n.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,61 @@ use anyhow::{Context, Result};
use serde::{Deserialize, Serialize};
use yuuka::derive_struct;

derive_struct!(pub Config {
header: {
welcome: String,
loading: String,
derive_struct!(
#[serde(rename_all = "kebab-case")]
pub Config {
header: {
welcome: String,
loading: String,

portal: String,
images: String,
users: String,
config: String,
portal: String,
images: String,
users: String,
config: String,

login: String,
logout: String,
register: String,
login: String,
logout: String,
register: String,

username: String,
password: String,
email: String,
username: String,
password: String,
email: String,

user: String,
manager: String,
},
portal: {
upload: String,
download: String,
delete: String,

progress: String,
fail: String,
},
images: {
total_count: String,
load_more: String,
},
config: {
user: String,
manager: String,
},
portal: {
engine_version: String,
language: String,
timezone: String,
title_suffix: String,
footer_banner: String,
upload: String,
download: String,
delete: String,

progress: String,
fail: String,
},
router: {
media_entry_path: String,
limit_referrer_host: String,
images: {
total_count: String,
load_more: String,
},
upload: {
image_size_limit: String,
webp_auto_convert: String,
use_source_file_name: String,
config: {
portal: {
engine_version: String,
language: String,
timezone: String,
title_suffix: String,
footer_banner: String,
},
router: {
media_entry_path: String,
limit_referrer_host: String,
},
upload: {
image_size_limit: String,
webp_auto_convert: String,
use_source_file_name: String,
},
},
},
});
}
);

#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
Expand Down

0 comments on commit 741c113

Please sign in to comment.