Skip to content

Commit

Permalink
Added localization for debug level selector
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Kozinko <xcariba@gmail.com>
  • Loading branch information
xcariba committed Jan 30, 2023
1 parent 7c559c8 commit 05ce583
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
26 changes: 20 additions & 6 deletions packages/core/src/common/severity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*--------------------------------------------------------------------------------------------*/

import { DiagnosticSeverity } from 'vscode-languageserver-protocol';
import { nls } from '../common';

export enum Severity {
Ignore = 0,
Expand All @@ -29,13 +30,13 @@ export enum Severity {
Log = 4
}

export namespace Severity {
const error = 'Errors';
const warning = 'Warnings';
const info = 'Info';
const log = 'Log';
const ignore = 'All';
const error = 'Errors';
const warning = 'Warnings';
const info = 'Info';
const log = 'Log';
const ignore = 'All';

export namespace Severity {
export function fromValue(value: string | undefined): Severity {
value = value && value.toLowerCase();

Expand Down Expand Up @@ -90,6 +91,19 @@ export namespace Severity {
}
}

export function toLocaleString(severity: string | Severity): string {
if (severity === Severity.Error || severity === error)
return nls.localize('theia/core/severity/errors', 'Errors');
else if (severity === Severity.Warning || severity === warning)
return nls.localize('theia/core/severity/warnings', 'Warnings');
else if (severity === Severity.Info || severity === info)
return nls.localize('theia/core/severity/info', 'Info');
else if (severity === Severity.Log || severity === log)
return nls.localize('theia/core/severity/log', 'Log');
else
return nls.localize('theia/core/severity/all', 'All');
}

export function toArray(): string[] {
return [ignore, error, warning, info, log];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ export class DebugConsoleContribution extends AbstractViewContribution<ConsoleWi

protected renderSeveritySelector(widget: Widget | undefined): React.ReactNode {
const severityElements: SelectOption[] = Severity.toArray().map(e => ({
value: e
value: e,
label: Severity.toLocaleString(e)
}));

return <SelectComponent
Expand Down

0 comments on commit 05ce583

Please sign in to comment.