Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(i18n): resolve prompt persistence and language menu behavior

imAaryash97fbb01801ab
diff --git a/src/components/launch/LaunchWindow.tsx b/src/components/launch/LaunchWindow.tsx
index a430be0a3..137b28cd3 100644
--- a/src/components/launch/LaunchWindow.tsx
+++ b/src/components/launch/LaunchWindow.tsx
@@ -89,6 +89,7 @@ export function LaunchWindow() {
systemLocaleSuggestion,
acceptSystemLocaleSuggestion,
dismissSystemLocaleSuggestion,
+ resolveSystemLocaleSuggestion,
} = useI18n();
const suggestedLanguageName = systemLocaleSuggestion ? getLocaleName(systemLocaleSuggestion) : "";
@@ -554,12 +555,15 @@ export function LaunchWindow() {
side="top"
sideOffset={6}
collisionPadding={6}
- className={`w-36 min-w-0 max-h-none overflow-hidden border-white/15 bg-[rgba(24,24,34,0.98)] p-1 text-white shadow-2xl backdrop-blur-xl ${styles.electronNoDrag}`}
+ className={`w-36 min-w-0 max-h-none overflow-y-hidden overflow-x-hidden border-white/15 bg-[rgba(24,24,34,0.98)] p-1 text-white shadow-2xl backdrop-blur-xl ${styles.electronNoDrag}`}
>
{SUPPORTED_LOCALES.map((loc) => (
<DropdownMenuItem
key={loc}
- onSelect={() => setLocale(loc)}
+ onSelect={() => {
+ setLocale(loc);
+ resolveSystemLocaleSuggestion();
+ }}
className={`flex items-center justify-between rounded-sm px-2 py-1.5 text-[11px] transition-colors ${loc === locale ? "text-white" : "text-white/90"} focus:bg-white/10 focus:text-white ${styles.electronNoDrag}`}
>
<span className="truncate">{getLocaleName(loc)}</span>
diff --git a/src/contexts/I18nContext.tsx b/src/contexts/I18nContext.tsx
index f9c5ee59d..84640eac1 100644
--- a/src/contexts/I18nContext.tsx
+++ b/src/contexts/I18nContext.tsx
@@ -26,6 +26,7 @@ interface I18nContextValue {
systemLocaleSuggestion: Locale | null;
acceptSystemLocaleSuggestion: () => void;
dismissSystemLocaleSuggestion: () => void;
+ resolveSystemLocaleSuggestion: () => void;
}
const SYSTEM_LANGUAGE_PROMPT_SEEN_KEY = "openscreen-system-language-prompt-seen";
@@ -152,12 +153,11 @@ export function I18nProvider({ children }: { children: ReactNode }) {
const dismissSystemLocaleSuggestion = useCallback(() => {
setSystemLocaleSuggestion(null);
- try {
- // Persisting default locale avoids showing this prompt again.
- localStorage.setItem(LOCALE_STORAGE_KEY, DEFAULT_LOCALE);
- } catch {
- // localStorage may be unavailable
- }
+ markPromptAsHandled();
+ }, [markPromptAsHandled]);
+
+ const resolveSystemLocaleSuggestion = useCallback(() => {
+ setSystemLocaleSuggestion(null);
markPromptAsHandled();
}, [markPromptAsHandled]);
@@ -180,6 +180,7 @@ export function I18nProvider({ children }: { children: ReactNode }) {
systemLocaleSuggestion,
acceptSystemLocaleSuggestion,
dismissSystemLocaleSuggestion,
+ resolveSystemLocaleSuggestion,
}),
[
locale,
@@ -188,6 +189,7 @@ export function I18nProvider({ children }: { children: ReactNode }) {
systemLocaleSuggestion,
acceptSystemLocaleSuggestion,
dismissSystemLocaleSuggestion,
+ resolveSystemLocaleSuggestion,
],
);