fix: localize auto-compact threshold settings

This commit is contained in:
Xiaohan-Tian
2026-06-03 17:38:34 -07:00
parent 42fdcebd42
commit 5c6e1d69c5
6 changed files with 34 additions and 6 deletions
@@ -178,7 +178,7 @@ describe('GeneralSettings', () => {
it('renders and persists the auto-compact threshold', async () => { it('renders and persists the auto-compact threshold', async () => {
renderSettings(); renderSettings();
const select = await screen.findByLabelText('Auto-Compact Threshold'); const select = await screen.findByLabelText(translate('settings.general.autoCompactThreshold.label', undefined, 'en_us'));
expect((select as HTMLSelectElement).value).toBe('90'); expect((select as HTMLSelectElement).value).toBe('90');
fireEvent.change(select, { target: { value: '80' } }); fireEvent.change(select, { target: { value: '80' } });
@@ -188,6 +188,14 @@ describe('GeneralSettings', () => {
}); });
}); });
it('renders the auto-compact threshold label from the zh_cn catalog', async () => {
renderSettings('zh_cn');
expect(
await screen.findByLabelText(translate('settings.general.autoCompactThreshold.label', undefined, 'zh_cn')),
).toBeTruthy();
});
it('renders and persists local runtime download URLs', async () => { it('renders and persists local runtime download URLs', async () => {
renderSettings(); renderSettings();
@@ -426,7 +426,7 @@ const GeneralSettings: React.FC = () => {
<div className="settings-item"> <div className="settings-item">
<label className="settings-label" htmlFor="general-auto-compact-threshold"> <label className="settings-label" htmlFor="general-auto-compact-threshold">
Auto-Compact Threshold {t('settings.general.autoCompactThreshold.label')}
</label> </label>
<select <select
id="general-auto-compact-threshold" id="general-auto-compact-threshold"
@@ -434,12 +434,12 @@ const GeneralSettings: React.FC = () => {
value={autoCompactThresholdPercent} value={autoCompactThresholdPercent}
onChange={(e) => void handleAutoCompactThresholdChange(e.target.value)} onChange={(e) => void handleAutoCompactThresholdChange(e.target.value)}
> >
<option value="95">Conservative (95%)</option> <option value="95">{t('settings.general.autoCompactThreshold.conservative')}</option>
<option value="90">Standard (90%)</option> <option value="90">{t('settings.general.autoCompactThreshold.standard')}</option>
<option value="80">Early (80%)</option> <option value="80">{t('settings.general.autoCompactThreshold.early')}</option>
</select> </select>
<div className="settings-help" style={{ fontSize: '12px', color: '#888', marginTop: '4px' }}> <div className="settings-help" style={{ fontSize: '12px', color: '#888', marginTop: '4px' }}>
Compact the conversation before the next request when estimated context usage reaches this level. {t('settings.general.autoCompactThreshold.help')}
</div> </div>
</div> </div>
</div> </div>
+5
View File
@@ -44,6 +44,11 @@ export const enUsMessages: TranslationMessages = {
'settings.general.llmProvider.openaiCompatible': 'OpenAI Compatible (e.g. OpenRouter, Ollama)', 'settings.general.llmProvider.openaiCompatible': 'OpenAI Compatible (e.g. OpenRouter, Ollama)',
'settings.general.persistKeys.label': 'Persist API Keys on Non-Localhost', 'settings.general.persistKeys.label': 'Persist API Keys on Non-Localhost',
'settings.general.persistKeys.help': 'When enabled, API keys will be saved to browser storage even on non-localhost environments. Warning: This may increase security vulnerability to XSS attacks.', 'settings.general.persistKeys.help': 'When enabled, API keys will be saved to browser storage even on non-localhost environments. Warning: This may increase security vulnerability to XSS attacks.',
'settings.general.autoCompactThreshold.label': 'Auto-Compact Threshold',
'settings.general.autoCompactThreshold.help': 'Compact the conversation before the next request when estimated context usage reaches this level.',
'settings.general.autoCompactThreshold.conservative': 'Conservative (95%)',
'settings.general.autoCompactThreshold.standard': 'Standard (90%)',
'settings.general.autoCompactThreshold.early': 'Early (80%)',
'settings.general.localRuntime.cachedStatus': 'Cached Model Status', 'settings.general.localRuntime.cachedStatus': 'Cached Model Status',
'settings.general.localRuntime.cacheChecking': 'Checking local model cache...', 'settings.general.localRuntime.cacheChecking': 'Checking local model cache...',
'settings.general.localRuntime.cacheDownloaded': 'Downloaded in browser cache.', 'settings.general.localRuntime.cacheDownloaded': 'Downloaded in browser cache.',
+5
View File
@@ -41,6 +41,11 @@ export const frFrMessages: TranslationMessages = {
'settings.general.llmProvider.openaiCompatible': 'Serveur compatible OpenAI (ex. OpenRouter, Ollama)', 'settings.general.llmProvider.openaiCompatible': 'Serveur compatible OpenAI (ex. OpenRouter, Ollama)',
'settings.general.persistKeys.label': 'Conserver les clés API hors localhost', 'settings.general.persistKeys.label': 'Conserver les clés API hors localhost',
'settings.general.persistKeys.help': 'Si cette option est activée, les clés API sont enregistrées dans le stockage du navigateur même hors localhost. Attention : cela peut augmenter le risque lié aux attaques XSS.', 'settings.general.persistKeys.help': 'Si cette option est activée, les clés API sont enregistrées dans le stockage du navigateur même hors localhost. Attention : cela peut augmenter le risque lié aux attaques XSS.',
'settings.general.autoCompactThreshold.label': 'Seuil dauto-compactage',
'settings.general.autoCompactThreshold.help': 'Compacte la conversation avant la prochaine requête lorsque lutilisation estimée du contexte atteint ce niveau.',
'settings.general.autoCompactThreshold.conservative': 'Prudent (95 %)',
'settings.general.autoCompactThreshold.standard': 'Standard (90 %)',
'settings.general.autoCompactThreshold.early': 'Précoce (80 %)',
'settings.general.localRuntime.cachedStatus': 'État du modèle en cache', 'settings.general.localRuntime.cachedStatus': 'État du modèle en cache',
'settings.general.localRuntime.cacheChecking': 'Vérification du cache du modèle local...', 'settings.general.localRuntime.cacheChecking': 'Vérification du cache du modèle local...',
'settings.general.localRuntime.cacheDownloaded': 'Téléchargé dans le cache du navigateur.', 'settings.general.localRuntime.cacheDownloaded': 'Téléchargé dans le cache du navigateur.',
+5
View File
@@ -42,6 +42,11 @@ export const zhCnMessages: TranslationMessages = {
'settings.general.llmProvider.openaiCompatible': 'OpenAI 兼容服务(例如 OpenRouter、Ollama', 'settings.general.llmProvider.openaiCompatible': 'OpenAI 兼容服务(例如 OpenRouter、Ollama',
'settings.general.persistKeys.label': '在非 localhost 环境持久化 API Key', 'settings.general.persistKeys.label': '在非 localhost 环境持久化 API Key',
'settings.general.persistKeys.help': '启用后,即使在非 localhost 环境下,API Key 也会保存到浏览器存储中。警告:这可能增加 XSS 攻击带来的安全风险。', 'settings.general.persistKeys.help': '启用后,即使在非 localhost 环境下,API Key 也会保存到浏览器存储中。警告:这可能增加 XSS 攻击带来的安全风险。',
'settings.general.autoCompactThreshold.label': '自动压缩阈值',
'settings.general.autoCompactThreshold.help': '当预估上下文使用量达到此级别时,在下一次请求前压缩对话。',
'settings.general.autoCompactThreshold.conservative': '保守(95%',
'settings.general.autoCompactThreshold.standard': '标准(90%',
'settings.general.autoCompactThreshold.early': '提前(80%',
'settings.general.localRuntime.cachedStatus': '缓存模型状态', 'settings.general.localRuntime.cachedStatus': '缓存模型状态',
'settings.general.localRuntime.cacheChecking': '正在检查本地模型缓存...', 'settings.general.localRuntime.cacheChecking': '正在检查本地模型缓存...',
'settings.general.localRuntime.cacheDownloaded': '已下载到浏览器缓存。', 'settings.general.localRuntime.cacheDownloaded': '已下载到浏览器缓存。',
+5
View File
@@ -42,6 +42,11 @@ export const zhHkMessages: TranslationMessages = {
'settings.general.llmProvider.openaiCompatible': 'OpenAI 兼容服務(例如 OpenRouter、Ollama', 'settings.general.llmProvider.openaiCompatible': 'OpenAI 兼容服務(例如 OpenRouter、Ollama',
'settings.general.persistKeys.label': '在非 localhost 環境持久化 API Key', 'settings.general.persistKeys.label': '在非 localhost 環境持久化 API Key',
'settings.general.persistKeys.help': '啟用後,即使在非 localhost 環境下,API Key 也會儲存到瀏覽器儲存空間中。警告:這可能增加 XSS 攻擊帶來的安全風險。', 'settings.general.persistKeys.help': '啟用後,即使在非 localhost 環境下,API Key 也會儲存到瀏覽器儲存空間中。警告:這可能增加 XSS 攻擊帶來的安全風險。',
'settings.general.autoCompactThreshold.label': '自動壓縮閾值',
'settings.general.autoCompactThreshold.help': '當預估上下文使用量達到此級別時,在下一次請求前壓縮對話。',
'settings.general.autoCompactThreshold.conservative': '保守(95%',
'settings.general.autoCompactThreshold.standard': '標準(90%',
'settings.general.autoCompactThreshold.early': '提前(80%',
'settings.general.localRuntime.cachedStatus': '緩存模型狀態', 'settings.general.localRuntime.cachedStatus': '緩存模型狀態',
'settings.general.localRuntime.cacheChecking': '正在檢查本地模型緩存...', 'settings.general.localRuntime.cacheChecking': '正在檢查本地模型緩存...',
'settings.general.localRuntime.cacheDownloaded': '已下載到瀏覽器緩存。', 'settings.general.localRuntime.cacheDownloaded': '已下載到瀏覽器緩存。',