feat: create a server function for getting the language identifier

This commit is contained in:
Matouš Volf 2024-09-10 16:14:28 +02:00
parent 4bfb322d14
commit d4ee2b4154
2 changed files with 15 additions and 0 deletions

View 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>()?)
}

View File

@ -2,3 +2,4 @@ mod database_connection;
pub(crate) mod projects;
pub(crate) mod tasks;
pub(crate) mod subtasks;
pub(crate) mod internationalization;