feat: add absolute dates/months to dictionary
This commit is contained in:
parent
c9433d721d
commit
d18f175aef
10 changed files with 9942 additions and 1834 deletions
|
|
@ -1,4 +1,34 @@
|
|||
#![cfg(test)]
|
||||
|
||||
use std::{collections::BTreeMap, fs::File, io::BufReader};
|
||||
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use crate::model::Language;
|
||||
mod collect_playlist_dates;
|
||||
mod gen_dictionary;
|
||||
mod gen_locales;
|
||||
|
||||
const DICT_PATH: &str = "testfiles/date/dictionary.json";
|
||||
|
||||
type Dictionary = BTreeMap<Language, DictEntry>;
|
||||
|
||||
#[derive(Debug, Default, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
struct DictEntry {
|
||||
equivalent: Vec<Language>,
|
||||
by_char: bool,
|
||||
timeago_tokens: BTreeMap<String, String>,
|
||||
date_order: String,
|
||||
months: BTreeMap<String, u8>,
|
||||
}
|
||||
|
||||
fn read_dict() -> Dictionary {
|
||||
let json_file = File::open(DICT_PATH).unwrap();
|
||||
serde_json::from_reader(BufReader::new(json_file)).unwrap()
|
||||
}
|
||||
|
||||
fn write_dict(dict: &Dictionary) {
|
||||
let json_file = File::create(DICT_PATH).unwrap();
|
||||
serde_json::to_writer_pretty(json_file, dict).unwrap();
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue