UPDATE: Dump of initial files
This commit is contained in:
82
base/src/language/language.json
Normal file
82
base/src/language/language.json
Normal file
@@ -0,0 +1,82 @@
|
||||
{
|
||||
"en": {
|
||||
"booleans": {
|
||||
"true": "TRUE",
|
||||
"false": "FALSE"
|
||||
},
|
||||
"errors":{
|
||||
"ref": "#REF!",
|
||||
"name": "#NAME?",
|
||||
"value": "#VALUE!",
|
||||
"div": "#DIV/0!",
|
||||
"na": "#N/A",
|
||||
"num": "#NUM!",
|
||||
"error": "#ERROR!",
|
||||
"nimpl": "#N/IMPL!",
|
||||
"spill": "#SPILL!",
|
||||
"null": "#NULL!",
|
||||
"calc": "#CALC!",
|
||||
"circ": "#CIRC!"
|
||||
}
|
||||
},
|
||||
"de": {
|
||||
"booleans": {
|
||||
"true": "WAHR",
|
||||
"false": "FALSCH"
|
||||
},
|
||||
"errors":{
|
||||
"ref": "#BEZUG!",
|
||||
"name": "#NAME?",
|
||||
"value": "#WERT!",
|
||||
"div": "#DIV/0!",
|
||||
"na": "#NV",
|
||||
"num": "#ZAHL!",
|
||||
"error": "#ERROR!",
|
||||
"nimpl": "#N/IMPL!",
|
||||
"spill": "#ÜBERLAUF!",
|
||||
"null": "#NULL!",
|
||||
"calc": "#CALC!",
|
||||
"circ": "#CIRC!"
|
||||
}
|
||||
},
|
||||
"fr": {
|
||||
"booleans": {
|
||||
"true": "VRAI",
|
||||
"false": "FAUX"
|
||||
},
|
||||
"errors":{
|
||||
"ref": "#REF!",
|
||||
"name": "#NOM?",
|
||||
"value": "#VALEUR!",
|
||||
"div": "#DIV/0!",
|
||||
"na": "#N/A",
|
||||
"num": "#NOMBRE!",
|
||||
"error": "#ERROR!",
|
||||
"nimpl": "#N/IMPL!",
|
||||
"spill": "#SPILL!",
|
||||
"null": "#NULL!",
|
||||
"calc": "#CALC!",
|
||||
"circ": "#CIRC!"
|
||||
}
|
||||
},
|
||||
"es": {
|
||||
"booleans": {
|
||||
"true": "VERDADERO",
|
||||
"false": "FALSO"
|
||||
},
|
||||
"errors": {
|
||||
"ref": "#¡REF!",
|
||||
"name": "#¿NOMBRE?",
|
||||
"value": "#¡VALOR!",
|
||||
"div": "#¡DIV/0!",
|
||||
"na": "#N/A",
|
||||
"num": "#¡NUM!",
|
||||
"error": "#ERROR!",
|
||||
"nimpl": "#N/IMPL!",
|
||||
"spill": "#SPILL!",
|
||||
"null": "#NULL!",
|
||||
"calc": "#CALC!",
|
||||
"circ": "#CIRC!"
|
||||
}
|
||||
}
|
||||
}
|
||||
46
base/src/language/mod.rs
Normal file
46
base/src/language/mod.rs
Normal file
@@ -0,0 +1,46 @@
|
||||
use once_cell::sync::Lazy;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct Booleans {
|
||||
#[serde(rename = "true")]
|
||||
pub true_value: String,
|
||||
#[serde(rename = "false")]
|
||||
pub false_value: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct Errors {
|
||||
#[serde(rename = "ref")]
|
||||
pub ref_value: String,
|
||||
pub name: String,
|
||||
pub value: String,
|
||||
pub div: String,
|
||||
pub na: String,
|
||||
pub num: String,
|
||||
pub nimpl: String,
|
||||
pub spill: String,
|
||||
pub calc: String,
|
||||
pub circ: String,
|
||||
pub error: String,
|
||||
pub null: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct Language {
|
||||
pub booleans: Booleans,
|
||||
pub errors: Errors,
|
||||
}
|
||||
|
||||
static LANGUAGES: Lazy<HashMap<String, Language>> = Lazy::new(|| {
|
||||
serde_json::from_str(include_str!("language.json")).expect("Failed parsing language file")
|
||||
});
|
||||
|
||||
pub fn get_language(id: &str) -> Result<&Language, String> {
|
||||
let language = LANGUAGES
|
||||
.get(id)
|
||||
.ok_or(format!("Language is not supported: '{}'", id))?;
|
||||
Ok(language)
|
||||
}
|
||||
Reference in New Issue
Block a user