From: Greg Burri Date: Fri, 3 Jan 2025 18:32:41 +0000 (+0100) Subject: Languages list is now sorted. X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=754d5ec9e3826bc62c86044401799cdadbee2661;p=recipes.git Languages list is now sorted. --- diff --git a/backend/src/consts.rs b/backend/src/consts.rs index 4385309..1b85736 100644 --- a/backend/src/consts.rs +++ b/backend/src/consts.rs @@ -1,4 +1,4 @@ -use std::time::Duration; +use std::{sync::LazyLock, time::Duration}; pub const FILE_CONF: &str = "conf.ron"; pub const DB_DIRECTORY: &str = "data"; @@ -21,4 +21,8 @@ pub const REVERSE_PROXY_IP_HTTP_FIELD: &str = "x-real-ip"; // Set by the reverse pub const MAX_DB_CONNECTION: u32 = 1; // To avoid database lock. -pub const LANGUAGES: [(&str, &str); 2] = [("Français", "fr"), ("English", "en")]; +pub static LANGUAGES: LazyLock<[(&str, &str); 2]> = LazyLock::new(|| { + let mut langs = [("Français", "fr"), ("English", "en")]; + langs.sort(); + langs +}); diff --git a/backend/src/services/recipe.rs b/backend/src/services/recipe.rs index aa69ce0..b6c872f 100644 --- a/backend/src/services/recipe.rs +++ b/backend/src/services/recipe.rs @@ -47,7 +47,7 @@ pub async fn edit_recipe( user: Some(user), recipes, recipe, - languages: consts::LANGUAGES, + languages: *consts::LANGUAGES, } .into_response()) } else { diff --git a/backend/templates/recipe_edit.html b/backend/templates/recipe_edit.html index 4b96b90..923d6d8 100644 --- a/backend/templates/recipe_edit.html +++ b/backend/templates/recipe_edit.html @@ -54,6 +54,26 @@ + +
+ +
+ +
+