From 43fb5efe4bcbae3576af4f108e6d96d558fb4b48 Mon Sep 17 00:00:00 2001 From: Denys Date: Sat, 31 Jan 2026 17:32:15 +0000 Subject: [PATCH 1/2] fix: persist user's locale in a cookie --- nuxt.config.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index 702481509c..61bbb01e2d 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -236,7 +236,11 @@ export default defineNuxtConfig({ locales: currentLocales, defaultLocale: 'en-US', strategy: 'no_prefix', - detectBrowserLanguage: false, + detectBrowserLanguage: { + useCookie: true, + cookieKey: 'npmx-locale', + fallbackLocale: 'en-US', + }, langDir: 'locales', }, }) From 4ebea989a7644d272349e2228231a8396161d839 Mon Sep 17 00:00:00 2001 From: Denys Date: Sat, 31 Jan 2026 19:29:55 +0000 Subject: [PATCH 2/2] fix: persists user's locale in settings and use a plugin to set it --- app/composables/useSettings.ts | 4 ++++ app/pages/settings.vue | 7 ++++++- app/plugins/i18n-loader.client.ts | 20 ++++++++++++++++++++ nuxt.config.ts | 6 +----- 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 app/plugins/i18n-loader.client.ts diff --git a/app/composables/useSettings.ts b/app/composables/useSettings.ts index 5ea3e87dd0..beeb75514d 100644 --- a/app/composables/useSettings.ts +++ b/app/composables/useSettings.ts @@ -1,6 +1,7 @@ import type { RemovableRef } from '@vueuse/core' import { useLocalStorage } from '@vueuse/core' import { ACCENT_COLORS } from '#shared/utils/constants' +import type { LocaleObject } from '@nuxtjs/i18n' type AccentColorId = keyof typeof ACCENT_COLORS @@ -16,6 +17,8 @@ export interface AppSettings { accentColorId: AccentColorId | null /** Hide platform-specific packages (e.g., @scope/pkg-linux-x64) from search results */ hidePlatformPackages: boolean + /** User-selected locale */ + selectedLocale: LocaleObject['code'] | null sidebar: { collapsed: string[] } @@ -26,6 +29,7 @@ const DEFAULT_SETTINGS: AppSettings = { includeTypesInInstall: true, accentColorId: null, hidePlatformPackages: true, + selectedLocale: null, sidebar: { collapsed: [], }, diff --git a/app/pages/settings.vue b/app/pages/settings.vue index 14b379c886..200171da92 100644 --- a/app/pages/settings.vue +++ b/app/pages/settings.vue @@ -1,7 +1,7 @@