Skip to content

Commit 1caedf3

Browse files
committed
fix: init_locale before menu bar, cleanup dead code, harden set_locale
1 parent 04801f0 commit 1caedf3

7 files changed

Lines changed: 17 additions & 17 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/app_menus.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use crate::{auth, report_if_error};
2323
use ai::workspace::WorkspaceMetadata;
2424
use csv::Writer;
2525
use enclose::enclose;
26-
use i18n;
2726
use itertools::Itertools;
2827
use settings::manager::SettingsManager;
2928
use settings::Setting as _;

app/src/lib.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,15 @@ fn run_internal(mut launch_mode: LaunchMode) -> Result<()> {
941941
let crash_recovery =
942942
crash_recovery::CrashRecovery::new(&launch_mode, prefs_for_public_settings);
943943

944+
// ── i18n init ────────────────────────────────────────────────────
945+
// Must run before any UI construction (menu bar, windows) so that
946+
// platform callbacks see the correct locale from the start.
947+
i18n::init_locale();
948+
log::info!(
949+
"i18n: initialized, active locale: {}",
950+
i18n::current_locale()
951+
);
952+
944953
// Set up the pty spawner before doing any meaningful work. We want to
945954
// ensure that the process is in the cleanest possible state (minimal opened
946955
// files, modified signal handlers, etc.) to avoid unexpected effects on
@@ -1082,11 +1091,6 @@ pub struct UpdateQuakeModeEventArg {
10821091
active_window_id: Option<WindowId>,
10831092
}
10841093

1085-
// ── i18n readiness ──────────────────────────────────────────────
1086-
1087-
/// Set to `true` after `warp_i18n::init()` succeeds.
1088-
// i18n is always-on; no feature gate needed.
1089-
10901094
/// Helper for i18n UI labels.
10911095
/// Looks up the translation key using the user's chosen locale.
10921096
/// Falls back to the provided English string if no translation exists.
@@ -1139,15 +1143,6 @@ pub(crate) fn initialize_app(
11391143
let user_defaults_on_startup = settings::init(startup_toml_parse_error, ctx);
11401144
timer.mark_interval_end("READ_USER_DEFAULTS_AND_INITIALIZE_SETTINGS");
11411145

1142-
// ── i18n init ────────────────────────────────────────────────
1143-
// Locale YAML files live in resources/bundled/locales/.
1144-
// Locale is detected from WARP_LANG env, system locale, or defaults to en.
1145-
i18n::init_locale();
1146-
log::info!(
1147-
"i18n: initialized, active locale: {}",
1148-
i18n::current_locale()
1149-
);
1150-
11511146
if FeatureFlag::UIZoom.is_enabled() {
11521147
ctx.set_zoom_factor(WindowSettings::as_ref(ctx).zoom_level.as_zoom_factor());
11531148
}

crates/i18n/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ publish.workspace = true
77
license.workspace = true
88

99
[dependencies]
10+
log = { workspace = true }
1011
serde_yaml.workspace = true
1112
sys-locale.workspace = true

crates/i18n/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ pub fn set_locale(locale: &str) {
5858

5959
if let Ok(mut current_locale) = CURRENT_LOCALE.write() {
6060
*current_locale = locale;
61+
} else {
62+
log::error!("i18n: CURRENT_LOCALE lock poisoned, locale not changed");
6163
}
6264
}
6365

@@ -314,7 +316,7 @@ fn flatten_value(prefix: &str, value: &serde_yaml::Value, translations: &mut Has
314316
};
315317

316318
// Filter out _comment keys so they never appear in lookups.
317-
if key == "_comment" && prefix.is_empty() {
319+
if key == "_comment" {
318320
continue;
319321
}
320322

crates/warp_features/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,9 @@ pub enum FeatureFlag {
878878
/// Enables the code review view for remote sessions.
879879
RemoteCodeReview,
880880

881-
/// Enable internationalization (i18n) support with localized UI strings.
881+
/// Reserved for future staged rollout of internationalization (i18n) support.
882+
/// The i18n system is currently always-on; this flag is unused but kept for
883+
/// potential per-user opt-in/opt-out gating.
882884
I18n,
883885
}
884886

protoc-29.3-linux-x86_64.zip

3.14 MB
Binary file not shown.

0 commit comments

Comments
 (0)