From 60ea97c6e908a72c62163b11045234f26b182e85 Mon Sep 17 00:00:00 2001 From: Fernando Dodino Date: Mon, 7 Oct 2024 22:04:39 -0300 Subject: [PATCH] i18n command message --- packages/client/src/commands.ts | 8 +++++--- packages/client/src/messages.ts | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 packages/client/src/messages.ts diff --git a/packages/client/src/commands.ts b/packages/client/src/commands.ts index 594dd42..00b505d 100644 --- a/packages/client/src/commands.ts +++ b/packages/client/src/commands.ts @@ -15,6 +15,8 @@ import { } from './platform-string-utils' import { COMMAND_RUN_ALL_TESTS, COMMAND_RUN_GAME, COMMAND_RUN_PROGRAM, COMMAND_RUN_TEST, COMMAND_START_REPL, wollokLSPExtensionCode } from './shared-definitions' import { DEFAULT_REPL_PORT, DEFAULT_GAME_PORT } from '../../server/src/settings' +import { getMessage } from 'wollok-ts' +import { lang, lspClientMessages } from './messages' export const subscribeWollokCommands = (context: ExtensionContext): void => { context.subscriptions.push(registerCLICommand(COMMAND_START_REPL, startRepl)) @@ -110,11 +112,11 @@ const registerCLICommand = ( ) const wollokCLITask = (task: string, name: string, cliCommands: Array) => { - const wollokCliPath: string = workspace.getConfiguration(wollokLSPExtensionCode).get('cli-path') - // TODO: i18n - but it's in the server + const wollokLSPConfiguration = workspace.getConfiguration(wollokLSPExtensionCode) + const wollokCliPath: string = wollokLSPConfiguration.get('cli-path') if (!wollokCliPath) { vscode.commands.executeCommand('workbench.action.openSettings', wollokLSPExtensionCode) - throw new Error('Missing configuration WollokLSP/cli-path. Set the path where wollok-ts-cli is located in order to run Wollok tasks') + throw new Error(getMessage({ message: 'missingWollokCliPath', language: lang(wollokLSPConfiguration.get('wollokLSP.language')), customMessages: lspClientMessages })) } const folder = workspace.workspaceFolders[0] diff --git a/packages/client/src/messages.ts b/packages/client/src/messages.ts new file mode 100644 index 0000000..8f300ca --- /dev/null +++ b/packages/client/src/messages.ts @@ -0,0 +1,17 @@ +import { LANGUAGES, Messages } from 'wollok-ts' + +export const languageDescription: { [key: string]: LANGUAGES } = { + Spanish: LANGUAGES.SPANISH, + English: LANGUAGES.ENGLISH, +} + +export const lang = (selectedLanguage: string): LANGUAGES => languageDescription[selectedLanguage] ?? LANGUAGES.ENGLISH + +export const lspClientMessages: Messages = { + [LANGUAGES.ENGLISH]: { + missingWollokCliPath: 'Falta configurar la ruta donde está instalado wollok-ts-cli. Este paso es necesario para ejecutar cualquier comando de Wollok.', + }, + [LANGUAGES.SPANISH]: { + missingWollokCliPath: 'Missing configuration WollokLSP/cli-path. Set the path where wollok-ts-cli is located in order to run Wollok tasks', + }, +} \ No newline at end of file