refactor(i18n): extract SUPPORTED_LANGUAGES to avoid duplication

Move language list to supportedLanguages.ts so TranslationContext and
settingsStore can import from a single source of truth, eliminating
the hardcoded array in setLanguageTransient.
This commit is contained in:
Isaias Tavares
2026-04-12 18:50:44 -03:00
parent abed22661a
commit 91f7c3778f
3 changed files with 25 additions and 19 deletions
+2 -2
View File
@@ -2,6 +2,7 @@ import { create } from 'zustand'
import { settingsApi } from '../api/client'
import type { Settings } from '../types'
import { getApiErrorMessage } from '../types'
import { SUPPORTED_LANGUAGE_CODES } from '../i18n/supportedLanguages'
interface SettingsState {
settings: Settings
@@ -64,8 +65,7 @@ export const useSettingsStore = create<SettingsState>((set, get) => ({
// Used for automatic detection (browser/server default) — only explicit user
// choices via the UI should be persisted.
setLanguageTransient: (lang: string) => {
const supported = ['de', 'en', 'es', 'fr', 'hu', 'nl', 'br', 'cs', 'pl', 'ru', 'zh', 'zh-TW', 'it', 'ar']
if (!supported.includes(lang)) return
if (!SUPPORTED_LANGUAGE_CODES.includes(lang)) return
set((state) => ({ settings: { ...state.settings, language: lang } }))
},