From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 0DD491FF1B3 for ; Fri, 12 Sep 2025 10:48:09 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 49D9527C45; Fri, 12 Sep 2025 10:48:05 +0200 (CEST) From: Dominik Csapak To: yew-devel@lists.proxmox.com Date: Fri, 12 Sep 2025 10:47:20 +0200 Message-ID: <20250912084732.1053980-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250912084732.1053980-1-d.csapak@proxmox.com> References: <20250912084732.1053980-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.026 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [language.rs, mod.rs] Subject: [yew-devel] [PATCH yew-widget-toolkit v2 1/3] state: language: add text direction setting X-BeenThere: yew-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Yew framework devel list at Proxmox List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Yew framework devel list at Proxmox Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: yew-devel-bounces@lists.proxmox.com Sender: "yew-devel" Languages can have a text direction that is not left-to-right (LTR), so add that setting to the LanguageInfo. Expose it only via a builder style method, since most languages don't need this. Signed-off-by: Dominik Csapak --- src/state/language.rs | 24 ++++++++++++++++++++---- src/state/mod.rs | 1 + 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/state/language.rs b/src/state/language.rs index 182dcc9..3848731 100644 --- a/src/state/language.rs +++ b/src/state/language.rs @@ -8,12 +8,21 @@ use crate::props::ExtractPrimaryKey; use super::{PersistentState, SharedState, SharedStateObserver}; +/// The text direction, default is LTR +#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] +pub enum TextDirection { + #[default] + Ltr, + Rtl, +} + #[derive(Clone, PartialEq, Debug)] pub struct LanguageInfo { - pub lang: String, // id (de, en, ...) - pub text: String, // Language name (native). - pub english_text: String, // English language name. - pub translated_text: String, // Translated language name. + pub lang: String, // id (de, en, ...) + pub text: String, // Language name (native). + pub english_text: String, // English language name. + pub translated_text: String, // Translated language name. + pub direction: TextDirection, // Text direction of the language } impl LanguageInfo { @@ -28,8 +37,15 @@ impl LanguageInfo { text: text.into(), translated_text: gettext(&english_text), english_text, + direction: Default::default(), } } + + /// Builder style method to set the text direction + pub fn direction(mut self, direction: TextDirection) -> Self { + self.direction = direction; + self + } } impl ExtractPrimaryKey for LanguageInfo { diff --git a/src/state/mod.rs b/src/state/mod.rs index 4cd37a0..ff91faa 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -40,6 +40,7 @@ pub use theme::{ mod language; pub use language::{ get_available_languages, set_available_languages, Language, LanguageInfo, LanguageObserver, + TextDirection, }; use crate::props::StorageLocation; -- 2.47.3 _______________________________________________ yew-devel mailing list yew-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel