mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-29 20:20:57 +00:00
feat(i18n): Add Internationalization Support for UI and LLM Output (#1058)
This commit is contained in:
parent
640f30655d
commit
48b77541c3
98 changed files with 4740 additions and 636 deletions
|
|
@ -15,15 +15,20 @@ import fs from 'fs/promises';
|
|||
import { MessageType } from '../types.js';
|
||||
import type { SlashCommand, SlashCommandActionReturn } from './types.js';
|
||||
import { CommandKind } from './types.js';
|
||||
import { t } from '../../i18n/index.js';
|
||||
|
||||
export const memoryCommand: SlashCommand = {
|
||||
name: 'memory',
|
||||
description: 'Commands for interacting with memory.',
|
||||
get description() {
|
||||
return t('Commands for interacting with memory.');
|
||||
},
|
||||
kind: CommandKind.BUILT_IN,
|
||||
subCommands: [
|
||||
{
|
||||
name: 'show',
|
||||
description: 'Show the current memory contents.',
|
||||
get description() {
|
||||
return t('Show the current memory contents.');
|
||||
},
|
||||
kind: CommandKind.BUILT_IN,
|
||||
action: async (context) => {
|
||||
const memoryContent = context.services.config?.getUserMemory() || '';
|
||||
|
|
@ -31,8 +36,8 @@ export const memoryCommand: SlashCommand = {
|
|||
|
||||
const messageContent =
|
||||
memoryContent.length > 0
|
||||
? `Current memory content from ${fileCount} file(s):\n\n---\n${memoryContent}\n---`
|
||||
: 'Memory is currently empty.';
|
||||
? `${t('Current memory content from {{count}} file(s):', { count: String(fileCount) })}\n\n---\n${memoryContent}\n---`
|
||||
: t('Memory is currently empty.');
|
||||
|
||||
context.ui.addItem(
|
||||
{
|
||||
|
|
@ -45,7 +50,9 @@ export const memoryCommand: SlashCommand = {
|
|||
subCommands: [
|
||||
{
|
||||
name: '--project',
|
||||
description: 'Show project-level memory contents.',
|
||||
get description() {
|
||||
return t('Show project-level memory contents.');
|
||||
},
|
||||
kind: CommandKind.BUILT_IN,
|
||||
action: async (context) => {
|
||||
try {
|
||||
|
|
@ -57,8 +64,14 @@ export const memoryCommand: SlashCommand = {
|
|||
|
||||
const messageContent =
|
||||
memoryContent.trim().length > 0
|
||||
? `Project memory content from ${projectMemoryPath}:\n\n---\n${memoryContent}\n---`
|
||||
: 'Project memory is currently empty.';
|
||||
? t(
|
||||
'Project memory content from {{path}}:\n\n---\n{{content}}\n---',
|
||||
{
|
||||
path: projectMemoryPath,
|
||||
content: memoryContent,
|
||||
},
|
||||
)
|
||||
: t('Project memory is currently empty.');
|
||||
|
||||
context.ui.addItem(
|
||||
{
|
||||
|
|
@ -71,7 +84,9 @@ export const memoryCommand: SlashCommand = {
|
|||
context.ui.addItem(
|
||||
{
|
||||
type: MessageType.INFO,
|
||||
text: 'Project memory file not found or is currently empty.',
|
||||
text: t(
|
||||
'Project memory file not found or is currently empty.',
|
||||
),
|
||||
},
|
||||
Date.now(),
|
||||
);
|
||||
|
|
@ -80,7 +95,9 @@ export const memoryCommand: SlashCommand = {
|
|||
},
|
||||
{
|
||||
name: '--global',
|
||||
description: 'Show global memory contents.',
|
||||
get description() {
|
||||
return t('Show global memory contents.');
|
||||
},
|
||||
kind: CommandKind.BUILT_IN,
|
||||
action: async (context) => {
|
||||
try {
|
||||
|
|
@ -96,8 +113,10 @@ export const memoryCommand: SlashCommand = {
|
|||
|
||||
const messageContent =
|
||||
globalMemoryContent.trim().length > 0
|
||||
? `Global memory content:\n\n---\n${globalMemoryContent}\n---`
|
||||
: 'Global memory is currently empty.';
|
||||
? t('Global memory content:\n\n---\n{{content}}\n---', {
|
||||
content: globalMemoryContent,
|
||||
})
|
||||
: t('Global memory is currently empty.');
|
||||
|
||||
context.ui.addItem(
|
||||
{
|
||||
|
|
@ -110,7 +129,9 @@ export const memoryCommand: SlashCommand = {
|
|||
context.ui.addItem(
|
||||
{
|
||||
type: MessageType.INFO,
|
||||
text: 'Global memory file not found or is currently empty.',
|
||||
text: t(
|
||||
'Global memory file not found or is currently empty.',
|
||||
),
|
||||
},
|
||||
Date.now(),
|
||||
);
|
||||
|
|
@ -121,16 +142,20 @@ export const memoryCommand: SlashCommand = {
|
|||
},
|
||||
{
|
||||
name: 'add',
|
||||
description:
|
||||
'Add content to the memory. Use --global for global memory or --project for project memory.',
|
||||
get description() {
|
||||
return t(
|
||||
'Add content to the memory. Use --global for global memory or --project for project memory.',
|
||||
);
|
||||
},
|
||||
kind: CommandKind.BUILT_IN,
|
||||
action: (context, args): SlashCommandActionReturn | void => {
|
||||
if (!args || args.trim() === '') {
|
||||
return {
|
||||
type: 'message',
|
||||
messageType: 'error',
|
||||
content:
|
||||
content: t(
|
||||
'Usage: /memory add [--global|--project] <text to remember>',
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -150,8 +175,9 @@ export const memoryCommand: SlashCommand = {
|
|||
return {
|
||||
type: 'message',
|
||||
messageType: 'error',
|
||||
content:
|
||||
content: t(
|
||||
'Usage: /memory add [--global|--project] <text to remember>',
|
||||
),
|
||||
};
|
||||
} else {
|
||||
// No scope specified, will be handled by the tool
|
||||
|
|
@ -162,8 +188,9 @@ export const memoryCommand: SlashCommand = {
|
|||
return {
|
||||
type: 'message',
|
||||
messageType: 'error',
|
||||
content:
|
||||
content: t(
|
||||
'Usage: /memory add [--global|--project] <text to remember>',
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +198,10 @@ export const memoryCommand: SlashCommand = {
|
|||
context.ui.addItem(
|
||||
{
|
||||
type: MessageType.INFO,
|
||||
text: `Attempting to save to memory ${scopeText}: "${fact}"`,
|
||||
text: t('Attempting to save to memory {{scope}}: "{{fact}}"', {
|
||||
scope: scopeText,
|
||||
fact,
|
||||
}),
|
||||
},
|
||||
Date.now(),
|
||||
);
|
||||
|
|
@ -185,21 +215,25 @@ export const memoryCommand: SlashCommand = {
|
|||
subCommands: [
|
||||
{
|
||||
name: '--project',
|
||||
description: 'Add content to project-level memory.',
|
||||
get description() {
|
||||
return t('Add content to project-level memory.');
|
||||
},
|
||||
kind: CommandKind.BUILT_IN,
|
||||
action: (context, args): SlashCommandActionReturn | void => {
|
||||
if (!args || args.trim() === '') {
|
||||
return {
|
||||
type: 'message',
|
||||
messageType: 'error',
|
||||
content: 'Usage: /memory add --project <text to remember>',
|
||||
content: t('Usage: /memory add --project <text to remember>'),
|
||||
};
|
||||
}
|
||||
|
||||
context.ui.addItem(
|
||||
{
|
||||
type: MessageType.INFO,
|
||||
text: `Attempting to save to project memory: "${args.trim()}"`,
|
||||
text: t('Attempting to save to project memory: "{{text}}"', {
|
||||
text: args.trim(),
|
||||
}),
|
||||
},
|
||||
Date.now(),
|
||||
);
|
||||
|
|
@ -213,21 +247,25 @@ export const memoryCommand: SlashCommand = {
|
|||
},
|
||||
{
|
||||
name: '--global',
|
||||
description: 'Add content to global memory.',
|
||||
get description() {
|
||||
return t('Add content to global memory.');
|
||||
},
|
||||
kind: CommandKind.BUILT_IN,
|
||||
action: (context, args): SlashCommandActionReturn | void => {
|
||||
if (!args || args.trim() === '') {
|
||||
return {
|
||||
type: 'message',
|
||||
messageType: 'error',
|
||||
content: 'Usage: /memory add --global <text to remember>',
|
||||
content: t('Usage: /memory add --global <text to remember>'),
|
||||
};
|
||||
}
|
||||
|
||||
context.ui.addItem(
|
||||
{
|
||||
type: MessageType.INFO,
|
||||
text: `Attempting to save to global memory: "${args.trim()}"`,
|
||||
text: t('Attempting to save to global memory: "{{text}}"', {
|
||||
text: args.trim(),
|
||||
}),
|
||||
},
|
||||
Date.now(),
|
||||
);
|
||||
|
|
@ -243,13 +281,15 @@ export const memoryCommand: SlashCommand = {
|
|||
},
|
||||
{
|
||||
name: 'refresh',
|
||||
description: 'Refresh the memory from the source.',
|
||||
get description() {
|
||||
return t('Refresh the memory from the source.');
|
||||
},
|
||||
kind: CommandKind.BUILT_IN,
|
||||
action: async (context) => {
|
||||
context.ui.addItem(
|
||||
{
|
||||
type: MessageType.INFO,
|
||||
text: 'Refreshing memory from source files...',
|
||||
text: t('Refreshing memory from source files...'),
|
||||
},
|
||||
Date.now(),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue