Skip to content

Commit

Permalink
localize Theia AI strings
Browse files Browse the repository at this point in the history
- Localize Agent Descriptions
- Localize Preferences
- Localize View Titles and Descriptions

fixes eclipse-theia#14825

Signed-off-by: Camille Letavernier <[email protected]>
  • Loading branch information
CamilleLetavernier authored and eneufeld committed Feb 14, 2025
1 parent 72ca8ed commit b108460
Show file tree
Hide file tree
Showing 28 changed files with 238 additions and 199 deletions.
8 changes: 5 additions & 3 deletions packages/ai-anthropic/src/browser/anthropic-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { PreferenceSchema } from '@theia/core/lib/browser/preferences/preference-contribution';
import { AI_CORE_PREFERENCES_TITLE } from '@theia/ai-core/lib/browser/ai-core-preferences';
import { nls } from '@theia/core';

export const API_KEY_PREF = 'ai-features.anthropic.AnthropicApiKey';
export const MODELS_PREF = 'ai-features.anthropic.AnthropicModels';
Expand All @@ -25,13 +26,14 @@ export const AnthropicPreferencesSchema: PreferenceSchema = {
properties: {
[API_KEY_PREF]: {
type: 'string',
markdownDescription: 'Enter an API Key of your official Anthropic Account. **Please note:** By using this preference the Anthropic API key will be stored in clear text\
on the machine running Theia. Use the environment variable `ANTHROPIC_API_KEY` to set the key securely.',
markdownDescription: nls.localize('theia/ai/anthropic/apiKey/description',
'Enter an API Key of your official Anthropic Account. **Please note:** By using this preference the Anthropic API key will be stored in clear text\
on the machine running Theia. Use the environment variable `ANTHROPIC_API_KEY` to set the key securely.'),
title: AI_CORE_PREFERENCES_TITLE,
},
[MODELS_PREF]: {
type: 'array',
description: 'Official Anthropic models to use',
description: nls.localize('theia/ai/anthropic/models/description', 'Official Anthropic models to use'),
title: AI_CORE_PREFERENCES_TITLE,
default: ['claude-3-5-sonnet-latest', 'claude-3-5-haiku-latest', 'claude-3-opus-latest'],
items: {
Expand Down
8 changes: 4 additions & 4 deletions packages/ai-chat-ui/src/browser/ai-chat-ui-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// *****************************************************************************

import { inject, injectable } from '@theia/core/shared/inversify';
import { CommandRegistry, isOSX, QuickInputButton, QuickInputService, QuickPickItem } from '@theia/core';
import { CommandRegistry, isOSX, nls, QuickInputButton, QuickInputService, QuickPickItem } from '@theia/core';
import { Widget } from '@theia/core/lib/browser';
import { AI_CHAT_NEW_CHAT_WINDOW_COMMAND, AI_CHAT_SHOW_CHATS_COMMAND, ChatCommands } from './chat-view-commands';
import { ChatAgentLocation, ChatService } from '@theia/ai-chat';
Expand All @@ -37,7 +37,7 @@ export class AIChatContribution extends AbstractViewContribution<ChatViewWidget>

protected static readonly REMOVE_CHAT_BUTTON: QuickInputButton = {
iconClass: 'codicon-remove-close',
tooltip: 'Remove Chat',
tooltip: nls.localize('theia/ai/chatUi/removeChat', 'Remove Chat'),
};

@inject(SecondaryWindowHandler)
Expand Down Expand Up @@ -90,13 +90,13 @@ export class AIChatContribution extends AbstractViewContribution<ChatViewWidget>
registry.registerItem({
id: AI_CHAT_NEW_CHAT_WINDOW_COMMAND.id,
command: AI_CHAT_NEW_CHAT_WINDOW_COMMAND.id,
tooltip: 'New Chat',
tooltip: nls.localizeByDefault('New Chat'),
isVisible: widget => this.isChatViewWidget(widget)
});
registry.registerItem({
id: AI_CHAT_SHOW_CHATS_COMMAND.id,
command: AI_CHAT_SHOW_CHATS_COMMAND.id,
tooltip: 'Show Chats...',
tooltip: nls.localizeByDefault('Show Chats...'),
isVisible: widget => this.isChatViewWidget(widget),
});
}
Expand Down
8 changes: 4 additions & 4 deletions packages/ai-chat-ui/src/browser/chat-input-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************
import { ChangeSet, ChangeSetElement, ChatChangeEvent, ChatModel, ChatRequestModel } from '@theia/ai-chat';
import { Disposable, UntitledResourceResolver } from '@theia/core';
import { Disposable, nls, UntitledResourceResolver } from '@theia/core';
import { ContextMenuRenderer, LabelProvider, Message, ReactWidget } from '@theia/core/lib/browser';
import { Deferred } from '@theia/core/lib/common/promise-util';
import { inject, injectable, optional, postConstruct } from '@theia/core/shared/inversify';
Expand Down Expand Up @@ -320,14 +320,14 @@ const ChatInput: React.FunctionComponent<ChatInputProperties> = (props: ChatInpu
};

const leftOptions = props.showContext ? [{
title: 'Attach elements to context',
title: nls.localize('theia/ai/chatUi/attachToContext', 'Attach elements to context'),
handler: () => { /* TODO */ },
className: 'codicon-add'
}] : [];

const rightOptions = inProgress
? [{
title: 'Cancel (Esc)',
title: nls.localize('theia/ai/chatUi/cancel', 'Cancel (Esc)'),
handler: () => {
const latestRequest = getLatestRequest(props.chatModel);
if (latestRequest) {
Expand All @@ -338,7 +338,7 @@ const ChatInput: React.FunctionComponent<ChatInputProperties> = (props: ChatInpu
className: 'codicon-stop-circle'
}]
: [{
title: 'Send (Enter)',
title: nls.localize('theia/ai/chatUi/send', 'Send (Enter)'),
handler: () => {
if (props.isEnabled) {
submit(editorRef.current?.document.textEditorModel.getValue() || '');
Expand Down
6 changes: 4 additions & 2 deletions packages/ai-chat/src/browser/ai-chat-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// *****************************************************************************

import { AI_CORE_PREFERENCES_TITLE } from '@theia/ai-core/lib/browser/ai-core-preferences';
import { nls } from '@theia/core';
import { PreferenceSchema } from '@theia/core/lib/browser/preferences/preference-contribution';

export const DEFAULT_CHAT_AGENT_PREF = 'ai-features.chat.defaultChatAgent';
Expand All @@ -24,8 +25,9 @@ export const aiChatPreferences: PreferenceSchema = {
properties: {
[DEFAULT_CHAT_AGENT_PREF]: {
type: 'string',
description: 'Optional: <agent-name> of the Chat Agent that shall be invoked, if no agent is explicitly mentioned with @<agent-name> in the user query.\
If no Default Agent is configured, Theia´s defaults will be applied.',
description: nls.localize('theia/ai/chat/defaultAgent/description',
'Optional: <agent-name> of the Chat Agent that shall be invoked, if no agent is explicitly mentioned with @<agent-name> in the user query. \
If no Default Agent is configured, Theia´s defaults will be applied.'),
title: AI_CORE_PREFERENCES_TITLE,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { PreferenceSchema } from '@theia/core/lib/browser/preferences/preference-contribution';
import { AI_CORE_PREFERENCES_TITLE } from '@theia/ai-core/lib/browser/ai-core-preferences';
import { nls } from '@theia/core';

export const PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE = 'ai-features.codeCompletion.automaticCodeCompletion';
export const PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS = 'ai-features.codeCompletion.excludedFileExtensions';
Expand All @@ -28,33 +29,36 @@ export const AICodeCompletionPreferencesSchema: PreferenceSchema = {
[PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE]: {
title: AI_CORE_PREFERENCES_TITLE,
type: 'boolean',
description: 'Automatically trigger AI completions inline within any (Monaco) editor while editing.\
description: nls.localize('theia/ai/completion/automaticEnable/description',
'Automatically trigger AI completions inline within any (Monaco) editor while editing.\
\n\
Alternatively, you can manually trigger the code via the command "Trigger Inline Suggestion" or the default shortcut "Ctrl+Alt+Space".',
Alternatively, you can manually trigger the code via the command "Trigger Inline Suggestion" or the default shortcut "Ctrl+Alt+Space".'),
default: true
},
[PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS]: {
title: 'Excluded File Extensions',
title: nls.localize('theia/ai/completion/excludedFileExts/title', 'Excluded File Extensions'),
type: 'array',
description: 'Specify file extensions (e.g., .md, .txt) where AI completions should be disabled.',
description: nls.localize('theia/ai/completion/excludedFileExts/description', 'Specify file extensions (e.g., .md, .txt) where AI completions should be disabled.'),
items: {
type: 'string'
},
default: []
},
[PREF_AI_INLINE_COMPLETION_MAX_CONTEXT_LINES]: {
title: 'Maximum Context Lines',
title: nls.localize('theia/ai/completion/maxContextLines/title', 'Maximum Context Lines'),
type: 'number',
description: 'The maximum number of lines used as context, distributed among the lines before and after the cursor position (prefix and suffix).\
Set this to -1 to use the full file as context without any line limit and 0 to only use the current line.',
description: nls.localize('theia/ai/completion/maxContextLines/description',
'The maximum number of lines used as context, distributed among the lines before and after the cursor position (prefix and suffix).\
Set this to -1 to use the full file as context without any line limit and 0 to only use the current line.'),
default: -1,
minimum: -1
},
[PREF_AI_INLINE_COMPLETION_STRIP_BACKTICKS]: {
title: 'Strip Backticks from Inline Completions',
title: nls.localize('theia/ai/completion/stripBackticks/title', 'Strip Backticks from Inline Completions'),
type: 'boolean',
description: 'Remove surrounding backticks from the code returned by some LLMs. If a backtick is detected, all content after the closing\
backtick is stripped as well. This setting helps ensure plain code is returned when language models use markdown-like formatting.',
description: nls.localize('theia/ai/completion/stripBackticks/description',
'Remove surrounding backticks from the code returned by some LLMs. If a backtick is detected, all content after the closing\
backtick is stripped as well. This setting helps ensure plain code is returned when language models use markdown-like formatting.'),
default: true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
Agent, AgentSpecificVariables, CommunicationRecordingService, getTextOfResponse,
LanguageModelRegistry, LanguageModelRequest, LanguageModelRequirement, PromptService, PromptTemplate
} from '@theia/ai-core/lib/common';
import { generateUuid, ILogger, ProgressService } from '@theia/core';
import { generateUuid, ILogger, nls, ProgressService } from '@theia/core';
import { inject, injectable, named } from '@theia/core/shared/inversify';
import * as monaco from '@theia/monaco-editor-core';
import { PREF_AI_INLINE_COMPLETION_MAX_CONTEXT_LINES } from './ai-code-completion-preference';
Expand Down Expand Up @@ -184,7 +184,7 @@ export class CodeCompletionAgentImpl implements CodeCompletionAgent {
id = 'Code Completion';
name = 'Code Completion';
description =
'This agent provides inline code completion in the code editor in the Theia IDE.';
nls.localize('theia/ai/completion/agent/description', 'This agent provides inline code completion in the code editor in the Theia IDE.');
promptTemplates: PromptTemplate[] = [
{
id: 'code-completion-prompt-previous',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { TemplateRenderer } from './template-settings-renderer';
import { AIConfigurationSelectionService } from './ai-configuration-service';
import { AIVariableConfigurationWidget } from './variable-configuration-widget';
import { AgentService } from '../../common/agent-service';
import { nls } from '@theia/core';

interface ParsedPrompt {
functions: string[];
Expand All @@ -44,7 +45,7 @@ interface ParsedPrompt {
export class AIAgentConfigurationWidget extends ReactWidget {

static readonly ID = 'ai-agent-configuration-container-widget';
static readonly LABEL = 'Agents';
static readonly LABEL = nls.localize('theia/ai/core/agentConfiguration/label', 'Agents');

@inject(AgentService)
protected readonly agentService: AgentService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import '../../../src/browser/style/index.css';
import { AIAgentConfigurationWidget } from './agent-configuration-widget';
import { AIVariableConfigurationWidget } from './variable-configuration-widget';
import { AIConfigurationSelectionService } from './ai-configuration-service';
import { nls } from '@theia/core';

@injectable()
export class AIConfigurationContainerWidget extends BaseWidget {

static readonly ID = 'ai-configuration';
static readonly LABEL = '✨ AI Configuration [Experimental]';
static readonly LABEL = nls.localize('theia/ai/core/aiConfiguration/label', '✨ AI Configuration [Experimental]');
protected dockpanel: DockPanel;

@inject(TheiaDockPanel.Factory)
Expand Down
19 changes: 11 additions & 8 deletions packages/ai-core/src/browser/ai-core-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { nls } from '@theia/core';
import { PreferenceContribution, PreferenceProxy, PreferenceSchema } from '@theia/core/lib/browser';
import { PreferenceProxyFactory } from '@theia/core/lib/browser/preferences/injectable-preference-proxy';
import { interfaces } from '@theia/core/shared/inversify';

export const AI_CORE_PREFERENCES_TITLE = '✨ AI Features [Experimental]';
export const AI_CORE_PREFERENCES_TITLE = nls.localize('theia/ai/core/prefs/title', '✨ AI Features [Experimental]');
export const PREFERENCE_NAME_ENABLE_EXPERIMENTAL = 'ai-features.AiEnable.enableAI';
export const PREFERENCE_NAME_PROMPT_TEMPLATES = 'ai-features.promptTemplates.promptTemplatesFolder';
export const PREFERENCE_NAME_REQUEST_SETTINGS = 'ai-features.modelSettings.requestSettings';
Expand All @@ -28,7 +29,8 @@ export const aiCorePreferenceSchema: PreferenceSchema = {
properties: {
[PREFERENCE_NAME_ENABLE_EXPERIMENTAL]: {
title: AI_CORE_PREFERENCES_TITLE,
markdownDescription: '❗ This setting allows you to access and experiment with the latest AI capabilities.\
markdownDescription: nls.localize('theia/ai/core/enableExperimental/mdDescription',
'❗ This setting allows you to access and experiment with the latest AI capabilities.\
\n\
Please note that these features are in an experimental phase, which means they may be unstable and\
undergo significant changes. It is important to be aware that these experimental features may generate\
Expand All @@ -37,14 +39,15 @@ export const aiCorePreferenceSchema: PreferenceSchema = {
\n\
**Please note! The settings below in this section will only take effect\n\
once the main feature setting is enabled. After enabling the feature, you need to configure at least one\
LLM provider below. Also see [the documentation](https://theia-ide.org/docs/user_ai/)**.',
LLM provider below. Also see [the documentation](https://theia-ide.org/docs/user_ai/)**.'),
type: 'boolean',
default: false,
},
[PREFERENCE_NAME_PROMPT_TEMPLATES]: {
title: AI_CORE_PREFERENCES_TITLE,
description: 'Folder for storing customized prompt templates. If not customized the user config directory is used. Please consider to use a folder, which is\
under version control to manage your variants of prompt templates.',
description: nls.localize('theia/ai/core/promptTemplates/description',
'Folder for storing customized prompt templates. If not customized the user config directory is used. Please consider to use a folder, which is\
under version control to manage your variants of prompt templates.'),
type: 'string',
default: '',
typeDetails: {
Expand All @@ -58,12 +61,12 @@ export const aiCorePreferenceSchema: PreferenceSchema = {
},
},
[PREFERENCE_NAME_REQUEST_SETTINGS]: {
title: 'Custom Request Settings',
markdownDescription: 'Allows specifying custom request settings for multiple models.\n\
title: nls.localize('theia/ai/core/requestSettings/title', 'Custom Request Settings'),
markdownDescription: nls.localize('theia/ai/core/requestSettings/mdDescription', 'Allows specifying custom request settings for multiple models.\n\
Each object represents the configuration for a specific model. The `modelId` field specifies the model ID, `requestSettings` defines model-specific settings.\n\
The `providerId` field is optional and allows you to apply the settings to a specific provider. If not set, the settings will be applied to all providers.\n\
Example providerIds: huggingface, openai, ollama, llamafile.\n\
Refer to [our documentation](https://theia-ide.org/docs/user_ai/#custom-request-settings) for more information.',
Refer to [our documentation](https://theia-ide.org/docs/user_ai/#custom-request-settings) for more information.'),
type: 'array',
items: {
type: 'object',
Expand Down
4 changes: 2 additions & 2 deletions packages/ai-core/src/browser/prompttemplate-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { inject, injectable } from '@theia/core/shared/inversify';
import { GrammarDefinition, GrammarDefinitionProvider, LanguageGrammarDefinitionContribution, TextmateRegistry } from '@theia/monaco/lib/browser/textmate';
import * as monaco from '@theia/monaco-editor-core';
import { Command, CommandContribution, CommandRegistry, MessageService } from '@theia/core';
import { Command, CommandContribution, CommandRegistry, MessageService, nls } from '@theia/core';
import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';

import { codicon, Widget } from '@theia/core/lib/browser';
Expand Down Expand Up @@ -245,7 +245,7 @@ export class PromptTemplateContribution implements LanguageGrammarDefinitionCont
registry.registerItem({
id: DISCARD_PROMPT_TEMPLATE_CUSTOMIZATIONS.id,
command: DISCARD_PROMPT_TEMPLATE_CUSTOMIZATIONS.id,
tooltip: 'Discard Customizations'
tooltip: nls.localize('theia/ai/core/discardCustomPrompt/tooltip', 'Discard Customizations')
});
}
}
4 changes: 2 additions & 2 deletions packages/ai-core/src/common/agents-variable-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
// *****************************************************************************
import { inject, injectable } from '@theia/core/shared/inversify';
import { AIVariable, AIVariableContext, AIVariableContribution, AIVariableResolutionRequest, AIVariableResolver, AIVariableService, ResolvedAIVariable } from './variable-service';
import { MaybePromise } from '@theia/core';
import { MaybePromise, nls } from '@theia/core';
import { AgentService } from './agent-service';

export const AGENTS_VARIABLE: AIVariable = {
id: 'agents',
name: 'agents',
description: 'Returns the list of agents available in the system'
description: nls.localize('theia/ai/core/agentsVariable/description', 'Returns the list of agents available in the system')
};

export interface ResolvedAgentsVariable extends ResolvedAIVariable {
Expand Down
Loading

0 comments on commit b108460

Please sign in to comment.