Translating Arduino-IDE using Theia's nls API (#545)

This commit is contained in:
Mark Sujew
2021-10-18 09:59:33 +02:00
committed by GitHub
parent 61262c23ac
commit 11b75bd610
76 changed files with 1445 additions and 499 deletions

View File

@@ -10,11 +10,15 @@ import {
import { ListWidget } from '../widgets/component-list/list-widget';
import { Installable } from '../../common/protocol';
import { ListItemRenderer } from '../widgets/component-list/list-item-renderer';
import { nls } from '@theia/core/lib/browser/nls';
@injectable()
export class LibraryListWidget extends ListWidget<LibraryPackage> {
static WIDGET_ID = 'library-list-widget';
static WIDGET_LABEL = 'Library Manager';
static WIDGET_LABEL = nls.localize(
'arduino/library/title',
'Library Manager'
);
constructor(
@inject(LibraryService) protected service: LibraryService,
@@ -61,11 +65,20 @@ export class LibraryListWidget extends ListWidget<LibraryPackage> {
let installDependencies: boolean | undefined = undefined;
if (dependencies.length) {
const message = document.createElement('div');
message.innerHTML = `The library <b>${item.name}:${version}</b> needs ${
message.innerHTML =
dependencies.length === 1
? 'another dependency'
: 'some other dependencies'
} currently not installed:`;
? nls.localize(
'arduino/library/needsOneDependency',
'The library <b>{0}:{1}</b> needs another dependency currently not installed:',
item.name,
version
)
: nls.localize(
'arduino/library/needsMultipleDependencies',
'The library <b>{0}:{1}</b> needs some other dependencies currently not installed:',
item.name,
version
);
const listContainer = document.createElement('div');
listContainer.style.maxHeight = '300px';
listContainer.style.overflowY = 'auto';
@@ -80,16 +93,34 @@ export class LibraryListWidget extends ListWidget<LibraryPackage> {
listContainer.appendChild(list);
message.appendChild(listContainer);
const question = document.createElement('div');
question.textContent = `Would you like to install ${
question.textContent =
dependencies.length === 1
? 'the missing dependency'
: 'all the missing dependencies'
}?`;
? nls.localize(
'arduino/library/installOneMissingDependency',
'Would you like to install the missing dependency?'
)
: nls.localize(
'arduino/library/installMissingDependencies',
'Would you like to install all the missing dependencies?'
);
message.appendChild(question);
const result = await new MessageBoxDialog({
title: `Dependencies for library ${item.name}:${version}`,
title: nls.localize(
'arduino/library/dependenciesForLibrary',
'Dependencies for library {0}:{1}',
item.name,
version
),
message,
buttons: ['Install all', `Install ${item.name} only`, 'Cancel'],
buttons: [
nls.localize('arduino/library/installAll', 'Install all'),
nls.localize(
'arduino/library/installOnly',
'Install {0} only',
item.name
),
nls.localize('vscode/issueMainService/cancel', 'Cancel'),
],
maxWidth: 740, // Aligned with `settings-dialog.css`.
}).open();
@@ -116,7 +147,12 @@ export class LibraryListWidget extends ListWidget<LibraryPackage> {
installDependencies,
});
this.messageService.info(
`Successfully installed library ${item.name}:${version}`,
nls.localize(
'arduino/library/installedSuccessfully',
'Successfully installed library {0}:{1}',
item.name,
version
),
{ timeout: 3000 }
);
}
@@ -131,7 +167,12 @@ export class LibraryListWidget extends ListWidget<LibraryPackage> {
}): Promise<void> {
await super.uninstall({ item, progressId });
this.messageService.info(
`Successfully uninstalled library ${item.name}:${item.installedVersion}`,
nls.localize(
'arduino/library/uninstalledSuccessfully',
'Successfully uninstalled library {0}:{1}',
item.name,
item.installedVersion!
),
{ timeout: 3000 }
);
}
@@ -143,7 +184,9 @@ class MessageBoxDialog extends AbstractDialog<MessageBoxDialog.Result> {
constructor(protected readonly options: MessageBoxDialog.Options) {
super(options);
this.contentNode.appendChild(this.createMessageNode(this.options.message));
(options.buttons || ['OK']).forEach((text, index) => {
(
options.buttons || [nls.localize('vscode/issueMainService/ok', 'OK')]
).forEach((text, index) => {
const button = this.createButton(text);
button.classList.add(index === 0 ? 'main' : 'secondary');
this.controlPanel.appendChild(button);