feat: added translation for Music Generator panel; provided K.G.Studio Musician Assistant a Chinese name

This commit is contained in:
Xiaohan-Tian
2026-05-30 20:29:10 -07:00
parent 957f6db950
commit b5546aa230
12 changed files with 711 additions and 267 deletions
@@ -111,6 +111,19 @@ describe('processUserMessage slash commands', () => {
expect(result.pseudoAssistantResponse).toContain('welcome_local_llm-zh_cn.md');
});
it('falls back to a localized welcome string when welcome markdown fetch fails', async () => {
configState.set('general.language', 'zh_cn');
configState.set('general.llm_provider', 'local_browser');
vi.stubGlobal('fetch', vi.fn(async () => {
throw new Error('network down');
}));
const result = await processUserMessage('/welcome');
expect(result.metadata).toMatchObject({ command: 'welcome' });
expect(result.pseudoAssistantResponse).toBe('欢迎使用 K.G.Studio 音乐创作助手。');
});
it('uses the new-user welcome for non-local providers without required config', async () => {
configState.set('general.llm_provider', 'openai');
configState.set('general.openai.api_key', '');
+4 -2
View File
@@ -5,6 +5,7 @@ import { SystemPrompts } from '../../agent/core/SystemPrompts';
import { detectLocalLLMRuntimeSupport, LOCAL_LLM_PROVIDER_KEY } from '../localLLMConfig';
import { normalizeLanguageSetting, resolveLanguageSetting } from '../../i18n/locale';
import type { ResolvedLocaleCode } from '../../i18n/types';
import { translate } from '../../i18n/translate';
export interface UserMessageFilterResult {
// Whether to render the user message bubble (div.message-user)
@@ -133,8 +134,8 @@ export async function processUserMessage(originalMessage: string): Promise<UserM
}
case '/welcome': {
const configManager = ConfigManager.instance();
try {
const configManager = ConfigManager.instance();
if (!configManager.getIsInitialized()) {
await configManager.initialize();
}
@@ -150,7 +151,8 @@ export async function processUserMessage(originalMessage: string): Promise<UserM
metadata: { command: 'welcome', variant }
};
} catch (err) {
const fallback = 'Welcome to K.G.Studio Musician Assistant.';
const locale = resolveCurrentCommandLocale(configManager);
const fallback = translate('assistant.welcomeFallback', undefined, locale);
return {
displayUserMessage: false,
sendToLLM: false,