feat: internationalization #43

Merged
matous-volf merged 8 commits from feat/internationalization into main 2024-09-10 14:44:47 +00:00
2 changed files with 15 additions and 0 deletions
Showing only changes of commit d2dd7c78b9 - Show all commits

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>()?)
}
coderabbitai[bot] commented 2024-09-10 14:34:32 +00:00 (Migrated from github.com)
Review

LGTM with nitpicks!

The server-side code for retrieving the language identifier looks good. Just a couple of nitpicks:

  1. If the LANGUAGE_CODE environment variable is always set by the deployment process, you can remove the dotenv import and the dotenv() call.

  2. Consider changing the visibility modifier from pub(crate) to pub for consistency with other server functions, unless you have a specific reason to restrict the visibility to the current crate.

**LGTM with nitpicks!** The server-side code for retrieving the language identifier looks good. Just a couple of nitpicks: 1. If the `LANGUAGE_CODE` environment variable is always set by the deployment process, you can remove the `dotenv` import and the `dotenv()` call. 2. Consider changing the visibility modifier from `pub(crate)` to `pub` for consistency with other server functions, unless you have a specific reason to restrict the visibility to the current crate. <!-- This is an auto-generated comment by CodeRabbit -->

View File

@ -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;