mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 09:17:53 +00:00
feat: add i18n for /agents command
This commit is contained in:
@@ -20,6 +20,7 @@ import type { Config } from '@qwen-code/qwen-code-core';
|
||||
import { theme } from '../../../semantic-colors.js';
|
||||
import { TextEntryStep } from './TextEntryStep.js';
|
||||
import { useKeypress } from '../../../hooks/useKeypress.js';
|
||||
import { t } from '../../../../i18n/index.js';
|
||||
|
||||
interface AgentCreationWizardProps {
|
||||
onClose: () => void;
|
||||
@@ -90,25 +91,25 @@ export function AgentCreationWizard({
|
||||
const n = state.currentStep;
|
||||
switch (kind) {
|
||||
case 'LOCATION':
|
||||
return `Step ${n}: Choose Location`;
|
||||
return t('Step {{n}}: Choose Location', { n: n.toString() });
|
||||
case 'GEN_METHOD':
|
||||
return `Step ${n}: Choose Generation Method`;
|
||||
return t('Step {{n}}: Choose Generation Method', { n: n.toString() });
|
||||
case 'LLM_DESC':
|
||||
return `Step ${n}: Describe Your Subagent`;
|
||||
return t('Step {{n}}: Describe Your Subagent', { n: n.toString() });
|
||||
case 'MANUAL_NAME':
|
||||
return `Step ${n}: Enter Subagent Name`;
|
||||
return t('Step {{n}}: Enter Subagent Name', { n: n.toString() });
|
||||
case 'MANUAL_PROMPT':
|
||||
return `Step ${n}: Enter System Prompt`;
|
||||
return t('Step {{n}}: Enter System Prompt', { n: n.toString() });
|
||||
case 'MANUAL_DESC':
|
||||
return `Step ${n}: Enter Description`;
|
||||
return t('Step {{n}}: Enter Description', { n: n.toString() });
|
||||
case 'TOOLS':
|
||||
return `Step ${n}: Select Tools`;
|
||||
return t('Step {{n}}: Select Tools', { n: n.toString() });
|
||||
case 'COLOR':
|
||||
return `Step ${n}: Choose Background Color`;
|
||||
return t('Step {{n}}: Choose Background Color', { n: n.toString() });
|
||||
case 'FINAL':
|
||||
return `Step ${n}: Confirm and Save`;
|
||||
return t('Step {{n}}: Confirm and Save', { n: n.toString() });
|
||||
default:
|
||||
return 'Unknown Step';
|
||||
return t('Unknown Step');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -163,11 +164,11 @@ export function AgentCreationWizard({
|
||||
// Special case: During generation in description input step, only show cancel option
|
||||
const kind = getStepKind(state.generationMethod, state.currentStep);
|
||||
if (kind === 'LLM_DESC' && state.isGenerating) {
|
||||
return 'Esc to cancel';
|
||||
return t('Esc to cancel');
|
||||
}
|
||||
|
||||
if (getStepKind(state.generationMethod, state.currentStep) === 'FINAL') {
|
||||
return 'Press Enter to save, e to save and edit, Esc to go back';
|
||||
return t('Press Enter to save, e to save and edit, Esc to go back');
|
||||
}
|
||||
|
||||
// Steps that have ↑↓ navigation (RadioButtonSelect components)
|
||||
@@ -177,14 +178,17 @@ export function AgentCreationWizard({
|
||||
kindForNav === 'GEN_METHOD' ||
|
||||
kindForNav === 'TOOLS' ||
|
||||
kindForNav === 'COLOR';
|
||||
const navigationPart = hasNavigation ? '↑↓ to navigate, ' : '';
|
||||
const navigationPart = hasNavigation ? t('↑↓ to navigate, ') : '';
|
||||
|
||||
const escAction =
|
||||
state.currentStep === WIZARD_STEPS.LOCATION_SELECTION
|
||||
? 'cancel'
|
||||
: 'go back';
|
||||
? t('cancel')
|
||||
: t('go back');
|
||||
|
||||
return `Press Enter to continue, ${navigationPart}Esc to ${escAction}`;
|
||||
return t('Press Enter to continue, {{navigation}}Esc to {{action}}', {
|
||||
navigation: navigationPart,
|
||||
action: escAction,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -210,16 +214,16 @@ export function AgentCreationWizard({
|
||||
state={state}
|
||||
dispatch={dispatch}
|
||||
onNext={handleNext}
|
||||
description="Enter a clear, unique name for this subagent."
|
||||
placeholder="e.g., Code Reviewer"
|
||||
description={t('Enter a clear, unique name for this subagent.')}
|
||||
placeholder={t('e.g., Code Reviewer')}
|
||||
height={1}
|
||||
initialText={state.generatedName}
|
||||
onChange={(t) => {
|
||||
const value = t; // keep raw, trim later when validating
|
||||
onChange={(text) => {
|
||||
const value = text; // keep raw, trim later when validating
|
||||
dispatch({ type: 'SET_GENERATED_NAME', name: value });
|
||||
}}
|
||||
validate={(t) =>
|
||||
t.trim().length === 0 ? 'Name cannot be empty.' : null
|
||||
validate={(text) =>
|
||||
text.trim().length === 0 ? t('Name cannot be empty.') : null
|
||||
}
|
||||
/>
|
||||
);
|
||||
@@ -230,18 +234,22 @@ export function AgentCreationWizard({
|
||||
state={state}
|
||||
dispatch={dispatch}
|
||||
onNext={handleNext}
|
||||
description="Write the system prompt that defines this subagent's behavior. Be comprehensive for best results."
|
||||
placeholder="e.g., You are an expert code reviewer..."
|
||||
description={t(
|
||||
"Write the system prompt that defines this subagent's behavior. Be comprehensive for best results.",
|
||||
)}
|
||||
placeholder={t('e.g., You are an expert code reviewer...')}
|
||||
height={10}
|
||||
initialText={state.generatedSystemPrompt}
|
||||
onChange={(t) => {
|
||||
onChange={(text) => {
|
||||
dispatch({
|
||||
type: 'SET_GENERATED_SYSTEM_PROMPT',
|
||||
systemPrompt: t,
|
||||
systemPrompt: text,
|
||||
});
|
||||
}}
|
||||
validate={(t) =>
|
||||
t.trim().length === 0 ? 'System prompt cannot be empty.' : null
|
||||
validate={(text) =>
|
||||
text.trim().length === 0
|
||||
? t('System prompt cannot be empty.')
|
||||
: null
|
||||
}
|
||||
/>
|
||||
);
|
||||
@@ -252,15 +260,24 @@ export function AgentCreationWizard({
|
||||
state={state}
|
||||
dispatch={dispatch}
|
||||
onNext={handleNext}
|
||||
description="Describe when and how this subagent should be used."
|
||||
placeholder="e.g., Reviews code for best practices and potential bugs."
|
||||
description={t(
|
||||
'Describe when and how this subagent should be used.',
|
||||
)}
|
||||
placeholder={t(
|
||||
'e.g., Reviews code for best practices and potential bugs.',
|
||||
)}
|
||||
height={6}
|
||||
initialText={state.generatedDescription}
|
||||
onChange={(t) => {
|
||||
dispatch({ type: 'SET_GENERATED_DESCRIPTION', description: t });
|
||||
onChange={(text) => {
|
||||
dispatch({
|
||||
type: 'SET_GENERATED_DESCRIPTION',
|
||||
description: text,
|
||||
});
|
||||
}}
|
||||
validate={(t) =>
|
||||
t.trim().length === 0 ? 'Description cannot be empty.' : null
|
||||
validate={(text) =>
|
||||
text.trim().length === 0
|
||||
? t('Description cannot be empty.')
|
||||
: null
|
||||
}
|
||||
/>
|
||||
);
|
||||
@@ -292,7 +309,9 @@ export function AgentCreationWizard({
|
||||
return (
|
||||
<Box>
|
||||
<Text color={theme.status.error}>
|
||||
Invalid step: {state.currentStep}
|
||||
{t('Invalid step: {{step}}', {
|
||||
step: state.currentStep.toString(),
|
||||
})}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user