Skip to content

Commit

Permalink
i18n extension texts
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Oct 9, 2024
1 parent 441c20b commit 26d861f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
7 changes: 3 additions & 4 deletions packages/client/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ import {
window,
workspace,
} from 'vscode'
import { DEFAULT_GAME_PORT, DEFAULT_REPL_PORT } from '../../server/src/settings'
import {
asShellString,
fsToShell,
} 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'
import { getLSPMessage } from './messages'

export const subscribeWollokCommands = (context: ExtensionContext): void => {
context.subscriptions.push(registerCLICommand(COMMAND_START_REPL, startRepl))
Expand Down Expand Up @@ -124,7 +123,7 @@ const wollokCLITask = (task: string, name: string, cliCommands: Array<string | v
const wollokCliPath: string = wollokLSPConfiguration.get('cli-path')
if (!wollokCliPath) {
vscode.commands.executeCommand('workbench.action.openSettings', wollokLSPExtensionCode)
throw new Error(getMessage({ message: 'missingWollokCliPath', language: lang(wollokLSPConfiguration.get('wollokLSP.language')), customMessages: lspClientMessages }))
throw new Error(getLSPMessage('missingWollokCliPath'))
}

const folder = workspace.workspaceFolders[0]
Expand Down
5 changes: 3 additions & 2 deletions packages/client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import {
TransportKind,
WorkDoneProgress,
} from 'vscode-languageclient/node'
import { WollokDebugAdapterFactory, WollokDebugConfigurationProvider } from '../../debug-adapter/src/index'
import { subscribeWollokCommands } from './commands'
import { getLSPMessage } from './messages'
import { wollokLSPExtensionId } from './shared-definitions'
import { allWollokFiles } from './utils'
import { WollokDebugAdapterFactory, WollokDebugConfigurationProvider } from '../../debug-adapter/src/index'

let client: LanguageClient

Expand Down Expand Up @@ -81,7 +82,7 @@ export function activate(context: ExtensionContext): void {

client.onProgress(WorkDoneProgress.type, 'wollok-build', (progress) => {
if (progress.kind === 'begin' || progress.kind === 'report') {
statusBarItem.text = '$(loading~spin) Wollok Building...'
statusBarItem.text = '$(loading~spin) ' + getLSPMessage('wollokBuilding')
statusBarItem.show()
} else {
statusBarItem.hide()
Expand Down
14 changes: 10 additions & 4 deletions packages/client/src/messages.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { LANGUAGES, Messages } from 'wollok-ts'
import { getMessage, LANGUAGES, Messages } from 'wollok-ts'
import { wollokLSPExtensionCode } from './shared-definitions'
import { workspace } from 'vscode'

export const languageDescription: { [key: string]: LANGUAGES } = {
Spanish: LANGUAGES.SPANISH,
Expand All @@ -9,9 +11,13 @@ export const lang = (selectedLanguage: string): LANGUAGES => languageDescription

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.',
missingWollokCliPath: 'Missing configuration WollokLSP/cli-path. Set the path where wollok-ts-cli is located in order to run Wollok tasks',
wollokBuilding: 'Wollok Building...',
},
[LANGUAGES.SPANISH]: {
missingWollokCliPath: 'Missing configuration WollokLSP/cli-path. Set the path where wollok-ts-cli is located in order to run Wollok tasks',
missingWollokCliPath: 'Falta configurar la ruta donde está instalado wollok-ts-cli. Este paso es necesario para ejecutar cualquier comando de Wollok.',
wollokBuilding: 'Generando Wollok...',
},
}
}

export const getLSPMessage = (message: string): string => getMessage({ message, language: lang(workspace.getConfiguration(wollokLSPExtensionCode).get('language')), customMessages: lspClientMessages })

0 comments on commit 26d861f

Please sign in to comment.