Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(desktop-gpui): hide the language picker in release builds unless CAP_GPUI_LANGUAGE_PICKER=1
Richie McIlroyb0e7e4d92606
diff --git a/apps/desktop-gpui/src/i18n/mod.rs b/apps/desktop-gpui/src/i18n/mod.rsindex 0d53fb843..c533865da 100644--- a/apps/desktop-gpui/src/i18n/mod.rs+++ b/apps/desktop-gpui/src/i18n/mod.rs@@ -13,6 +13,10 @@ pub const SETTING_KEY: &str = "uiLanguage";/// `CAP_GPUI_LOCALE=ja` (or `pseudo` in a debug build).pub const LOCALE_ENV: &str = "CAP_GPUI_LOCALE";const SYSTEM_SETTING: &str = "system";+/// Shows the language picker in a release build. Release builds hide it until+/// the main surfaces are translated; `uiLanguage` and [`LOCALE_ENV`] work+/// either way.+pub const PICKER_ENV: &str = "CAP_GPUI_LANGUAGE_PICKER";static CURRENT: AtomicU8 = AtomicU8::new(Locale::En as u8);@@ -54,6 +58,14 @@ impl Preference {}}+/// Read once: the General page asks on every render.+pub fn picker_enabled() -> bool {+ static ENABLED: OnceLock<bool> = OnceLock::new();+ *ENABLED.get_or_init(|| {+ cfg!(debug_assertions) || std::env::var(PICKER_ENV).is_ok_and(|value| value == "1")+ })+}+/// Before the first lookup: `main` calls this ahead of the theme, menus and/// tray.pub fn init(setting: Option<&str>) {diff --git a/apps/desktop-gpui/src/i18n/tests.rs b/apps/desktop-gpui/src/i18n/tests.rsindex 0ed3eb567..30f3ba98f 100644--- a/apps/desktop-gpui/src/i18n/tests.rs+++ b/apps/desktop-gpui/src/i18n/tests.rs@@ -457,6 +457,13 @@ fn language_picker_english() {);}+#[test]+fn the_picker_shows_in_debug_builds() {+ if cfg!(debug_assertions) {+ assert!(picker_enabled());+ }+}+#[test]fn system_tags_resolve_to_catalogs() {for (tag, expected) in [diff --git a/apps/desktop-gpui/src/settings_window.rs b/apps/desktop-gpui/src/settings_window.rsindex 06bcfd445..c17391622 100644--- a/apps/desktop-gpui/src/settings_window.rs+++ b/apps/desktop-gpui/src/settings_window.rs@@ -2981,9 +2981,12 @@ impl SettingsWindow {// -- The General page --------------------------------------------------fn render_general(&self, window: &Window, cx: &mut Context<Self>) -> Vec<gpui::AnyElement> {- vec![- self.render_appearance(cx).into_any_element(),- self.render_language(cx).into_any_element(),+ let mut sections = Vec::with_capacity(10);+ sections.push(self.render_appearance(cx).into_any_element());+ if i18n::picker_enabled() {+ sections.push(self.render_language(cx).into_any_element());+ }+ sections.extend([self.render_app_section(cx).into_any_element(),self.render_recording(cx).into_any_element(),self.render_storage(cx).into_any_element(),@@ -2992,7 +2995,8 @@ impl SettingsWindow {self.render_updates(cx).into_any_element(),self.render_self_host(window, cx).into_any_element(),self.render_privacy(cx).into_any_element(),- ]+ ]);+ sections}/// `AppearanceSection` -- `theme`.