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
|
|
@ -10,6 +10,7 @@ import { MessageType } from '../types.js';
|
|||
import * as os from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
import { loadServerHierarchicalMemory } from '@qwen-code/qwen-code-core';
|
||||
import { t } from '../../i18n/index.js';
|
||||
|
||||
export function expandHomeDir(p: string): string {
|
||||
if (!p) {
|
||||
|
|
@ -27,13 +28,18 @@ export function expandHomeDir(p: string): string {
|
|||
export const directoryCommand: SlashCommand = {
|
||||
name: 'directory',
|
||||
altNames: ['dir'],
|
||||
description: 'Manage workspace directories',
|
||||
get description() {
|
||||
return t('Manage workspace directories');
|
||||
},
|
||||
kind: CommandKind.BUILT_IN,
|
||||
subCommands: [
|
||||
{
|
||||
name: 'add',
|
||||
description:
|
||||
'Add directories to the workspace. Use comma to separate multiple paths',
|
||||
get description() {
|
||||
return t(
|
||||
'Add directories to the workspace. Use comma to separate multiple paths',
|
||||
);
|
||||
},
|
||||
kind: CommandKind.BUILT_IN,
|
||||
action: async (context: CommandContext, args: string) => {
|
||||
const {
|
||||
|
|
@ -46,7 +52,7 @@ export const directoryCommand: SlashCommand = {
|
|||
addItem(
|
||||
{
|
||||
type: MessageType.ERROR,
|
||||
text: 'Configuration is not available.',
|
||||
text: t('Configuration is not available.'),
|
||||
},
|
||||
Date.now(),
|
||||
);
|
||||
|
|
@ -63,7 +69,7 @@ export const directoryCommand: SlashCommand = {
|
|||
addItem(
|
||||
{
|
||||
type: MessageType.ERROR,
|
||||
text: 'Please provide at least one path to add.',
|
||||
text: t('Please provide at least one path to add.'),
|
||||
},
|
||||
Date.now(),
|
||||
);
|
||||
|
|
@ -74,8 +80,9 @@ export const directoryCommand: SlashCommand = {
|
|||
return {
|
||||
type: 'message' as const,
|
||||
messageType: 'error' as const,
|
||||
content:
|
||||
content: t(
|
||||
'The /directory add command is not supported in restrictive sandbox profiles. Please use --include-directories when starting the session instead.',
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -88,7 +95,12 @@ export const directoryCommand: SlashCommand = {
|
|||
added.push(pathToAdd.trim());
|
||||
} catch (e) {
|
||||
const error = e as Error;
|
||||
errors.push(`Error adding '${pathToAdd.trim()}': ${error.message}`);
|
||||
errors.push(
|
||||
t("Error adding '{{path}}': {{error}}", {
|
||||
path: pathToAdd.trim(),
|
||||
error: error.message,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -117,12 +129,21 @@ export const directoryCommand: SlashCommand = {
|
|||
addItem(
|
||||
{
|
||||
type: MessageType.INFO,
|
||||
text: `Successfully added GEMINI.md files from the following directories if there are:\n- ${added.join('\n- ')}`,
|
||||
text: t(
|
||||
'Successfully added GEMINI.md files from the following directories if there are:\n- {{directories}}',
|
||||
{
|
||||
directories: added.join('\n- '),
|
||||
},
|
||||
),
|
||||
},
|
||||
Date.now(),
|
||||
);
|
||||
} catch (error) {
|
||||
errors.push(`Error refreshing memory: ${(error as Error).message}`);
|
||||
errors.push(
|
||||
t('Error refreshing memory: {{error}}', {
|
||||
error: (error as Error).message,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
if (added.length > 0) {
|
||||
|
|
@ -133,7 +154,9 @@ export const directoryCommand: SlashCommand = {
|
|||
addItem(
|
||||
{
|
||||
type: MessageType.INFO,
|
||||
text: `Successfully added directories:\n- ${added.join('\n- ')}`,
|
||||
text: t('Successfully added directories:\n- {{directories}}', {
|
||||
directories: added.join('\n- '),
|
||||
}),
|
||||
},
|
||||
Date.now(),
|
||||
);
|
||||
|
|
@ -150,7 +173,9 @@ export const directoryCommand: SlashCommand = {
|
|||
},
|
||||
{
|
||||
name: 'show',
|
||||
description: 'Show all directories in the workspace',
|
||||
get description() {
|
||||
return t('Show all directories in the workspace');
|
||||
},
|
||||
kind: CommandKind.BUILT_IN,
|
||||
action: async (context: CommandContext) => {
|
||||
const {
|
||||
|
|
@ -161,7 +186,7 @@ export const directoryCommand: SlashCommand = {
|
|||
addItem(
|
||||
{
|
||||
type: MessageType.ERROR,
|
||||
text: 'Configuration is not available.',
|
||||
text: t('Configuration is not available.'),
|
||||
},
|
||||
Date.now(),
|
||||
);
|
||||
|
|
@ -173,7 +198,9 @@ export const directoryCommand: SlashCommand = {
|
|||
addItem(
|
||||
{
|
||||
type: MessageType.INFO,
|
||||
text: `Current workspace directories:\n${directoryList}`,
|
||||
text: t('Current workspace directories:\n{{directories}}', {
|
||||
directories: directoryList,
|
||||
}),
|
||||
},
|
||||
Date.now(),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue