feat: create a server function for getting the language identifier
This commit is contained in:
parent
4bfb322d14
commit
d4ee2b4154
14
src/server/internationalization.rs
Normal file
14
src/server/internationalization.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
use std::env;
|
||||||
|
use dioxus::prelude::ServerFnError;
|
||||||
|
use unic_langid_impl::LanguageIdentifier;
|
||||||
|
use dioxus::prelude::*;
|
||||||
|
use dotenvy::dotenv;
|
||||||
|
|
||||||
|
#[server]
|
||||||
|
pub(crate) async fn get_language_identifier() -> Result<LanguageIdentifier, ServerFnError> {
|
||||||
|
dotenv().expect("Could not load environment variables from the .env file.");
|
||||||
|
|
||||||
|
Ok(env::var("LANGUAGE_CODE")
|
||||||
|
.expect("The environment variable LANGUAGE_CODE must be set.")
|
||||||
|
.parse::<LanguageIdentifier>()?)
|
||||||
|
}
|
@ -2,3 +2,4 @@ mod database_connection;
|
|||||||
pub(crate) mod projects;
|
pub(crate) mod projects;
|
||||||
pub(crate) mod tasks;
|
pub(crate) mod tasks;
|
||||||
pub(crate) mod subtasks;
|
pub(crate) mod subtasks;
|
||||||
|
pub(crate) mod internationalization;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user