⚙️ feat: Add configurable trust checkbox labels for MCP Server Dialog (#10820)

Co-authored-by: Atef Bellaaj <slalom.bellaaj@external.daimlertruck.com>
This commit is contained in:
Atef Bellaaj 2025-12-05 17:03:30 +01:00 committed by Danny Avila
parent 394bb6242b
commit 9400148175
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
5 changed files with 91 additions and 4 deletions

View file

@ -34,3 +34,4 @@ export { default as useSpeechToText } from './Input/useSpeechToText';
export { default as useTextToSpeech } from './Input/useTextToSpeech';
export { default as useGenerationsByLatest } from './useGenerationsByLatest';
export { useResourcePermissions } from './useResourcePermissions';
export { default as useLocalizedConfig } from './useLocalizedConfig';

View file

@ -0,0 +1,36 @@
import { useRecoilValue } from 'recoil';
import store from '~/store';
type LocalizedValue = string | Record<string, string> | undefined;
/**
* Hook to resolve localized config values based on current user language.
* Automatically retrieves the current language from Recoil state.
*
* @returns A function to resolve localized values
*/
export default function useLocalizedConfig() {
const lang = useRecoilValue(store.lang);
/**
* Resolves a localized config value.
* @param value - Either a string or object with language codes as keys
* @param fallback - Fallback value if config is undefined or language not found
* @returns The resolved string value
*/
return (value: LocalizedValue, fallback: string): string => {
if (value === undefined) {
return fallback;
}
if (typeof value === 'string') {
return value;
}
// Extract base language code (e.g., 'de' from 'de-DE')
const baseLang = lang?.split('-')[0] ?? 'en';
// Try exact locale (de-DE), then base language (de), then 'en', then first available
return (
(lang && value[lang]) || value[baseLang] || value['en'] || Object.values(value)[0] || fallback
);
};
}