Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat: localize update settings and make available updates downloadable
Ilya6d9b15f59258
diff --git a/apps/desktop-gpui/locales/de.toml b/apps/desktop-gpui/locales/de.tomlindex 63f4d260b..c9e0a86b7 100644--- a/apps/desktop-gpui/locales/de.toml+++ b/apps/desktop-gpui/locales/de.toml@@ -29,6 +29,7 @@ settings = "Einstellungen…"close_window = "Fenster schließen"title = "Ablage"open_file = "Datei öffnen…"+open_recent = "Zuletzt geöffnet"import_media = "Medien importieren…"[menu.edit]@@ -604,3 +605,10 @@ download = "Update herunterladen…"checking = "Suche nach Updates…"downloading = "Update wird geladen…"restart = "Zum Aktualisieren neu starten…"++[settings.general.updates.download_policy]+auto = "Automatisch"+description = "Wähle, ob Cap Updates automatisch herunterlädt."+label = "Update-Downloads"+manual = "Manuell"+never = "Nie"diff --git a/apps/desktop-gpui/locales/en.toml b/apps/desktop-gpui/locales/en.tomlindex ef413074e..bb2e02dda 100644--- a/apps/desktop-gpui/locales/en.toml+++ b/apps/desktop-gpui/locales/en.toml@@ -29,6 +29,7 @@ settings = "Settings…"close_window = "Close Window"title = "File"open_file = "Open File…"+open_recent = "Open Recent"import_media = "Import Media…"[menu.edit]@@ -606,3 +607,10 @@ download = "Download update…"checking = "Checking for Update…"downloading = "Downloading update…"restart = "Restart to update…"++[settings.general.updates.download_policy]+auto = "Auto"+description = "Choose whether Cap downloads updates automatically."+label = "Update downloads"+manual = "Manual"+never = "Never"diff --git a/apps/desktop-gpui/locales/es.toml b/apps/desktop-gpui/locales/es.tomlindex cbdeb9b3b..9902bdbf4 100644--- a/apps/desktop-gpui/locales/es.toml+++ b/apps/desktop-gpui/locales/es.toml@@ -29,6 +29,7 @@ settings = "Ajustes…"close_window = "Cerrar ventana"title = "Archivo"open_file = "Abrir archivo…"+open_recent = "Abrir reciente"import_media = "Importar contenido…"[menu.edit]@@ -604,3 +605,10 @@ download = "Descargar actualización…"checking = "Buscando actualizaciones…"downloading = "Descargando actualización…"restart = "Reiniciar para actualizar…"++[settings.general.updates.download_policy]+auto = "Automático"+description = "Elige si Cap descarga las actualizaciones automáticamente."+label = "Descargas de actualizaciones"+manual = "Manual"+never = "Nunca"diff --git a/apps/desktop-gpui/locales/fr.toml b/apps/desktop-gpui/locales/fr.tomlindex 4a4fb35c8..52bda480d 100644--- a/apps/desktop-gpui/locales/fr.toml+++ b/apps/desktop-gpui/locales/fr.toml@@ -29,6 +29,7 @@ settings = "Paramètres…"close_window = "Fermer la fenêtre"title = "Fichier"open_file = "Ouvrir un fichier…"+open_recent = "Ouvrir récent"import_media = "Importer des médias…"[menu.edit]@@ -604,3 +605,10 @@ download = "Télécharger la mise à jour…"checking = "Recherche de mises à jour…"downloading = "Téléchargement de la mise à jour…"restart = "Redémarrer pour mettre à jour…"++[settings.general.updates.download_policy]+auto = "Automatique"+description = "Choisissez si Cap télécharge les mises à jour automatiquement."+label = "Téléchargements de mises à jour"+manual = "Manuel"+never = "Jamais"diff --git a/apps/desktop-gpui/locales/hi.toml b/apps/desktop-gpui/locales/hi.tomlindex f5c7e858c..715ae5ada 100644--- a/apps/desktop-gpui/locales/hi.toml+++ b/apps/desktop-gpui/locales/hi.toml@@ -29,6 +29,7 @@ settings = "सेटिंग्स…"close_window = "विंडो बंद करें"title = "फ़ाइल"open_file = "फ़ाइल खोलें…"+open_recent = "हाल ही में खोलें"import_media = "मीडिया इम्पोर्ट करें…"[menu.edit]@@ -604,3 +605,10 @@ download = "अपडेट डाउनलोड करें…"checking = "अपडेट जाँच रहे हैं…"downloading = "अपडेट डाउनलोड हो रहा है…"restart = "अपडेट करने के लिए फिर से शुरू करें…"++[settings.general.updates.download_policy]+auto = "स्वचालित"+description = "चुनें कि Cap अपडेट स्वचालित रूप से डाउनलोड करे या नहीं।"+label = "अपडेट डाउनलोड"+manual = "मैन्युअल"+never = "कभी नहीं"diff --git a/apps/desktop-gpui/locales/ja.toml b/apps/desktop-gpui/locales/ja.tomlindex ef6f8e1c8..f1981a814 100644--- a/apps/desktop-gpui/locales/ja.toml+++ b/apps/desktop-gpui/locales/ja.toml@@ -29,6 +29,7 @@ settings = "設定…"close_window = "ウィンドウを閉じる"title = "ファイル"open_file = "ファイルを開く…"+open_recent = "最近使った項目を開く"import_media = "メディアを読み込む…"[menu.edit]@@ -604,3 +605,10 @@ download = "アップデートをダウンロード…"checking = "アップデートを確認中…"downloading = "アップデートをダウンロード中…"restart = "アップデートのために再起動…"++[settings.general.updates.download_policy]+auto = "自動"+description = "Cap がアップデートを自動でダウンロードするか選択します。"+label = "アップデートのダウンロード"+manual = "手動"+never = "しない"diff --git a/apps/desktop-gpui/locales/zh-CN.toml b/apps/desktop-gpui/locales/zh-CN.tomlindex 1cae2a1bb..4e0405648 100644--- a/apps/desktop-gpui/locales/zh-CN.toml+++ b/apps/desktop-gpui/locales/zh-CN.toml@@ -29,6 +29,7 @@ settings = "设置…"close_window = "关闭窗口"title = "文件"open_file = "打开文件…"+open_recent = "打开最近使用"import_media = "导入媒体…"[menu.edit]@@ -604,3 +605,10 @@ download = "下载更新…"checking = "正在检查更新…"downloading = "正在下载更新…"restart = "重新启动以更新…"++[settings.general.updates.download_policy]+auto = "自动"+description = "选择 Cap 是否自动下载更新。"+label = "更新下载"+manual = "手动"+never = "从不"diff --git a/apps/desktop-gpui/src/i18n/tests.rs b/apps/desktop-gpui/src/i18n/tests.rsindex 29ce251da..204b555af 100644--- a/apps/desktop-gpui/src/i18n/tests.rs+++ b/apps/desktop-gpui/src/i18n/tests.rs@@ -26,6 +26,7 @@ fn english_matches_the_literals_it_replaced() {(tr::menu::app::preferences(), "Preferences…".into()),(tr::menu::file::close_window(), "Close Window".into()),(tr::menu::file::open_file(), "Open File…".into()),+ (tr::menu::file::open_recent(), "Open Recent".into()),(tr::menu::file::import_media(), "Import Media…".into()),(tr::menu::file::title(), "File".into()),(tr::menu::edit::copy(), "Copy".into()),@@ -415,6 +416,26 @@ fn english_matches_the_literals_it_replaced() {"Versioned releases (recommended)".into(),),(tr::settings::general::updates::title(), "Updates".into()),+ (+ tr::settings::general::updates::download_policy::label(),+ "Update downloads".into(),+ ),+ (+ tr::settings::general::updates::download_policy::description(),+ "Choose whether Cap downloads updates automatically.".into(),+ ),+ (+ tr::settings::general::updates::download_policy::manual(),+ "Manual".into(),+ ),+ (+ tr::settings::general::updates::download_policy::auto(),+ "Auto".into(),+ ),+ (+ tr::settings::general::updates::download_policy::never(),+ "Never".into(),+ ),(tr::settings::general::updates::channel::description(),"Which release channel Cap updates from.".into(),diff --git a/apps/desktop-gpui/src/menus.rs b/apps/desktop-gpui/src/menus.rsindex eaab9b33b..1f5873813 100644--- a/apps/desktop-gpui/src/menus.rs+++ b/apps/desktop-gpui/src/menus.rs@@ -307,6 +307,18 @@ pub(crate) fn refresh_update_menu(cx: &mut App) {install_menus(cx);}+pub(crate) fn reapply_update_row(cx: &mut App) {+ if !cx.has_global::<MenuRegistration>() {+ return;+ }+ let row = UpdateRow::of(&updates::status(cx));+ cx.global_mut::<MenuRegistration>().0 = row.clone();+ #[cfg(target_os = "macos")]+ platform::set_update_menu_item(row.title, row.badge.as_deref(), row.enabled);+ #[cfg(not(target_os = "macos"))]+ install_menus(cx);+}+fn install_menus(cx: &mut App) {let update_status = updates::status(cx);cx.set_menus(build_menus(&update_status));diff --git a/apps/desktop-gpui/src/platform.rs b/apps/desktop-gpui/src/platform.rsindex 51e365ab9..14f042966 100644--- a/apps/desktop-gpui/src/platform.rs+++ b/apps/desktop-gpui/src/platform.rs@@ -764,15 +764,18 @@ mod mac {return;};let has_recent_menu = file_menu.itemAtIndex(OPEN_RECENT_ROW).is_some_and(|item| {- item.title()- .isEqualToString(&NSString::from_str("Open Recent"))+ item.title().isEqualToString(&NSString::from_str(+ crate::i18n::tr::menu::file::open_recent(),+ ))});if has_recent_menu {return;}let recent_menu = NSMenu::new(main_thread);- recent_menu.setTitle(&NSString::from_str("Open Recent"));+ recent_menu.setTitle(&NSString::from_str(+ crate::i18n::tr::menu::file::open_recent(),+ ));let name = NSString::from_str("NSRecentDocumentsMenu");let key = NSString::from_str("menuName");let registered = exception::catch(AssertUnwindSafe(|| {@@ -783,7 +786,9 @@ mod mac {}let recent_item = NSMenuItem::new(main_thread);- recent_item.setTitle(&NSString::from_str("Open Recent"));+ recent_item.setTitle(&NSString::from_str(+ crate::i18n::tr::menu::file::open_recent(),+ ));recent_item.setSubmenu(Some(&recent_menu));recent_item.setAllowsAutomaticKeyEquivalentLocalization(true);file_menu.insertItem_atIndex(&recent_item, OPEN_RECENT_ROW);diff --git a/apps/desktop-gpui/src/settings_window.rs b/apps/desktop-gpui/src/settings_window.rsindex ccebc63e5..ddcb111ee 100644--- a/apps/desktop-gpui/src/settings_window.rs+++ b/apps/desktop-gpui/src/settings_window.rs@@ -4448,6 +4448,7 @@ impl SettingsWindow {},)),)+ .child(div().h(px(1.)).bg(theme.settings_border())).child(div().flex()@@ -4461,20 +4462,44 @@ impl SettingsWindow {.flex_col().gap(px(2.)).min_w_0()- .child(div().text_size(px(13.)).child("Update downloads"))+ .child(+ div()+ .text_size(px(13.))+ .child(tr::settings::general::updates::download_policy::label()),+ ).child(div().text_size(px(12.)).line_height(px(16.)).text_color(theme.settings_muted())- .child("Choose whether Cap downloads updates automatically."),+ .child(+ tr::settings::general::updates::download_policy::description(),+ ),),)- .child(self.segmented::<UpdateDownloadPolicy>(+ .child(self.segmented_raw("update-download-policy",- current_policy,+ vec![+ ui::SegmentOption::new(+ tr::settings::general::updates::download_policy::manual(),+ current_policy == UpdateDownloadPolicy::Manual,+ ),+ ui::SegmentOption::new(+ tr::settings::general::updates::download_policy::auto(),+ current_policy == UpdateDownloadPolicy::Auto,+ ),+ ui::SegmentOption::new(+ tr::settings::general::updates::download_policy::never(),+ current_policy == UpdateDownloadPolicy::Never,+ ),+ ],cx,- |this, value, cx| {+ |this, index, cx| {+ let value = match index {+ 0 => UpdateDownloadPolicy::Manual,+ 1 => UpdateDownloadPolicy::Auto,+ _ => UpdateDownloadPolicy::Never,+ };if this.settings.update_download_policy == value {return;}diff --git a/apps/desktop-gpui/src/updates.rs b/apps/desktop-gpui/src/updates.rsindex c00b8cda3..63d9c6785 100644--- a/apps/desktop-gpui/src/updates.rs+++ b/apps/desktop-gpui/src/updates.rs@@ -72,6 +72,7 @@ struct UpdateScheduler {manual_in_flight: bool,status: UpdateStatus,download_policy: UpdateDownloadPolicy,+ simulation_version: Option<Version>,staged: Option<StagedUpdate>,download: Option<gpui::Task<()>>,download_epoch: u64,@@ -188,6 +189,17 @@ pub(crate) fn check_manually(cx: &mut App) {prompt_restart(cx);return;}+ UpdateStatus::Downloading {+ version,+ fraction: None,+ } if cx+ .try_global::<UpdateScheduler>()+ .and_then(|scheduler| scheduler.simulation_version.as_ref())+ == Some(&version) =>+ {+ simulate_download(version, cx);+ return;+ }UpdateStatus::Downloading { version, .. } | UpdateStatus::Installing { version } => {cx.spawn(async move |_| {crate::platform::activate_app();@@ -285,6 +297,7 @@ fn harness_update_version() -> Option<Version> {#[cfg(debug_assertions)]fn simulate_update(version: Version, cx: &mut App) {tracing::info!(%version, "CAP_GPUI_UPDATE_SIMULATION_VERSION: available");+ cx.global_mut::<UpdateScheduler>().simulation_version = Some(version.clone());set_status(UpdateStatus::Downloading {version: version.clone(),@@ -292,22 +305,39 @@ fn simulate_update(version: Version, cx: &mut App) {},cx,);+ cx.spawn(async move |cx| {+ cx.background_executor()+ .timer(Duration::from_millis(400))+ .await;+ cx.update(crate::menus::reapply_update_row);+ })+ .detach();+if GeneralSettings::load().update_download_policy != UpdateDownloadPolicy::Auto {tracing::info!("CAP_GPUI_UPDATE_SIMULATION_VERSION: manual policy, waiting");return;}cx.spawn(async move |cx| {cx.background_executor().timer(Duration::from_secs(3)).await;- cx.update(|cx| {- tracing::info!(%version, "CAP_GPUI_UPDATE_SIMULATION_VERSION: downloading");- set_status(- UpdateStatus::Downloading {- version: version.clone(),- fraction: Some(0.0),- },- cx,- );- });+ cx.update(|cx| simulate_download(version, cx));+ })+ .detach();+}++#[cfg(debug_assertions)]+fn simulate_download(version: Version, cx: &mut App) {+ if !matches!(status(cx), UpdateStatus::Downloading { fraction: None, .. }) {+ return;+ }+ tracing::info!(%version, "CAP_GPUI_UPDATE_SIMULATION_VERSION: downloading");+ set_status(+ UpdateStatus::Downloading {+ version: version.clone(),+ fraction: Some(0.0),+ },+ cx,+ );+ cx.spawn(async move |cx| {for step in 1..=10u8 {cx.background_executor().timer(Duration::from_millis(800))@@ -330,6 +360,9 @@ fn simulate_update(version: Version, cx: &mut App) {.detach();}+#[cfg(not(debug_assertions))]+fn simulate_download(_version: Version, _cx: &mut App) {}+pub(crate) fn schedule_startup_check(cx: &mut App) {let (wake, requests) = flume::bounded(1);cx.set_global(UpdateScheduler {@@ -338,6 +371,7 @@ pub(crate) fn schedule_startup_check(cx: &mut App) {manual_in_flight: false,status: UpdateStatus::Idle,download_policy: GeneralSettings::load().update_download_policy,+ simulation_version: None,staged: None,download: None,download_epoch: 0,