feat(client): add RU/EN localization and native capture preview
This commit is contained in:
parent
8e5ab56611
commit
8460fb28fd
43 changed files with 4103 additions and 275 deletions
|
|
@ -4,6 +4,16 @@ use slint::{Model, ModelRc, SharedString, VecModel};
|
|||
|
||||
use crate::ui::state::{ConnState, UiState};
|
||||
|
||||
fn presence_label(status: &str) -> String {
|
||||
crate::ui::i18n::text(match status.to_ascii_lowercase().as_str() {
|
||||
"online" => "Online",
|
||||
"idle" | "away" => "Idle",
|
||||
"dnd" | "busy" => "Do not disturb",
|
||||
"pending" => "Pending",
|
||||
_ => "Offline",
|
||||
})
|
||||
}
|
||||
|
||||
type MainWindow = crate::ui::slint::MainWindow;
|
||||
type BookmarkItem = crate::ui::slint::BookmarkItem;
|
||||
type ChannelItem = crate::ui::slint::ChannelItem;
|
||||
|
|
@ -68,7 +78,9 @@ fn set_messages(
|
|||
other.content.chars().take(90).collect::<String>()
|
||||
)
|
||||
})
|
||||
.unwrap_or_else(|| "Original message unavailable".into())
|
||||
.unwrap_or_else(|| {
|
||||
crate::ui::i18n::text("Original message unavailable")
|
||||
})
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
),
|
||||
|
|
@ -100,7 +112,7 @@ fn set_members_state(window: &MainWindow, state: &UiState, ch_id: &str) {
|
|||
avatar_text: nick.chars().take(2).collect::<String>().into(),
|
||||
user_id: SharedString::from(user_id),
|
||||
nickname: SharedString::from(nick.as_str()),
|
||||
status: SharedString::from(status),
|
||||
status: presence_label(status).into(),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
|
@ -161,7 +173,7 @@ fn sync_sidebar(window: &MainWindow, state: &UiState, own_nickname: &str) {
|
|||
});
|
||||
|
||||
window.set_username(SharedString::from(own_nickname));
|
||||
window.set_user_status(SharedString::from("online"));
|
||||
window.set_user_status(crate::ui::i18n::text("Online").into());
|
||||
window.set_show_dms(state.browsing_dms);
|
||||
window.set_active_dm_id(state.active_dm_id.as_deref().unwrap_or("").into());
|
||||
window.set_replying_to_message(SharedString::from(
|
||||
|
|
@ -240,6 +252,14 @@ fn sync_friends(window: &MainWindow, state: &UiState) {
|
|||
.map(|f| FriendItem {
|
||||
user_id: SharedString::from(f.user_id.as_str()),
|
||||
nickname: SharedString::from(f.nickname.as_str()),
|
||||
status_label: presence_label(
|
||||
state
|
||||
.presences
|
||||
.get(&f.user_id)
|
||||
.map(|p| p.status.as_str())
|
||||
.unwrap_or("offline"),
|
||||
)
|
||||
.into(),
|
||||
status: SharedString::from(
|
||||
state
|
||||
.presences
|
||||
|
|
@ -259,7 +279,8 @@ fn sync_friends(window: &MainWindow, state: &UiState) {
|
|||
.map(|f| FriendItem {
|
||||
user_id: SharedString::from(f.user_id.as_str()),
|
||||
nickname: SharedString::from(f.nickname.as_str()),
|
||||
status: SharedString::from("pending"),
|
||||
status: "pending".into(),
|
||||
status_label: presence_label("pending").into(),
|
||||
})
|
||||
.collect();
|
||||
replace_model(window.get_pending_requests(), pending, |model| {
|
||||
|
|
@ -323,11 +344,14 @@ pub fn sync_voice(window: &MainWindow, state: &UiState) {
|
|||
));
|
||||
|
||||
let banner = match (state.local_speaking, state.remote_speaking) {
|
||||
(true, true) => "you and others are talking".to_string(),
|
||||
(true, false) => "you are talking".to_string(),
|
||||
(false, true) => format!(
|
||||
"{} is talking",
|
||||
state.nick_for(&state.last_remote_speaker_id)
|
||||
(true, true) => crate::ui::i18n::text("You and others are talking"),
|
||||
(true, false) => crate::ui::i18n::text("You are talking"),
|
||||
(false, true) => crate::ui::i18n::format(
|
||||
"{name} is talking",
|
||||
&[(
|
||||
"name",
|
||||
state.nick_for(&state.last_remote_speaker_id).to_string(),
|
||||
)],
|
||||
),
|
||||
_ => String::new(),
|
||||
};
|
||||
|
|
@ -347,7 +371,11 @@ pub fn sync_connect(window: &MainWindow, state: &UiState) {
|
|||
window.set_bookmarks(model)
|
||||
});
|
||||
window.set_status_text(SharedString::from(
|
||||
state.status_msg.as_deref().unwrap_or(""),
|
||||
state
|
||||
.status_msg
|
||||
.as_ref()
|
||||
.map(ToString::to_string)
|
||||
.unwrap_or_default(),
|
||||
));
|
||||
window.set_connecting(matches!(
|
||||
state.conn,
|
||||
|
|
@ -372,18 +400,30 @@ pub fn sync_settings(window: &MainWindow, state: &UiState, own_pubkey: &str) {
|
|||
window.set_output_device_index(state.output_device as i32);
|
||||
|
||||
window.set_passphrase_error(SharedString::from(
|
||||
state.settings_passphrase_error.as_deref().unwrap_or(""),
|
||||
state
|
||||
.settings_passphrase_error
|
||||
.as_ref()
|
||||
.map(ToString::to_string)
|
||||
.unwrap_or_default(),
|
||||
));
|
||||
|
||||
window.set_export_output(SharedString::from(
|
||||
state.settings_export_output.as_deref().unwrap_or(""),
|
||||
));
|
||||
window.set_export_error(SharedString::from(
|
||||
state.settings_export_error.as_deref().unwrap_or(""),
|
||||
state
|
||||
.settings_export_error
|
||||
.as_ref()
|
||||
.map(ToString::to_string)
|
||||
.unwrap_or_default(),
|
||||
));
|
||||
|
||||
window.set_import_error(SharedString::from(
|
||||
state.settings_import_error.as_deref().unwrap_or(""),
|
||||
state
|
||||
.settings_import_error
|
||||
.as_ref()
|
||||
.map(ToString::to_string)
|
||||
.unwrap_or_default(),
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue