Skip to content

Commit

Permalink
i18n command message
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Oct 9, 2024
1 parent 6e1d85d commit 441c20b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/client/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, COMMAND_INIT_PROJECT } 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))
Expand Down Expand Up @@ -118,11 +120,11 @@ const registerCLICommand = (
)

const wollokCLITask = (task: string, name: string, cliCommands: Array<string | vscode.ShellQuotedString>) => {
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]
Expand Down
17 changes: 17 additions & 0 deletions packages/client/src/messages.ts
Original file line number Diff line number Diff line change
@@ -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',
},
}

0 comments on commit 441c20b

Please sign in to comment.