From: Dominik Csapak <d.csapak@proxmox.com>
To: yew-devel@lists.proxmox.com
Subject: [yew-devel] [PATCH yew-widget-toolkit v2 1/3] state: language: add text direction setting
Date: Fri, 12 Sep 2025 10:47:20 +0200 [thread overview]
Message-ID: <20250912084732.1053980-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250912084732.1053980-1-d.csapak@proxmox.com>
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 <d.csapak@proxmox.com>
---
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
next prev parent reply other threads:[~2025-09-12 8:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-12 8:47 [yew-devel] [PATCH yew-comp/yew-widget-toolkit v2 0/4] Enable RTL text direction for relevant languages Dominik Csapak
2025-09-12 8:47 ` Dominik Csapak [this message]
2025-09-12 8:47 ` [yew-devel] [PATCH yew-widget-toolkit v2 2/3] widget: rtl switcher: refactor setting rtl direction Dominik Csapak
2025-09-12 8:47 ` [yew-devel] [PATCH yew-widget-toolkit v2 3/3] widget: language selector: automatically set text direction from language Dominik Csapak
2025-09-12 8:47 ` [yew-devel] [PATCH yew-comp v2 1/1] languages: add text direction information where necessary Dominik Csapak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250912084732.1053980-2-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=yew-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.