Fixed missing translations

Aligned the languge pack versions.

Closes #1431

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta
2022-09-15 15:50:21 +02:00
committed by Akos Kitta
parent 707f3bef61
commit 9ef04bb8d6
18 changed files with 235 additions and 349 deletions

View File

@@ -53,8 +53,6 @@ import {
DockPanelRenderer as TheiaDockPanelRenderer,
TabBarRendererFactory,
ContextMenuRenderer,
createTreeContainer,
TreeWidget,
} from '@theia/core/lib/browser';
import { MenuContribution } from '@theia/core/lib/common/menu';
import {
@@ -207,12 +205,8 @@ import { WorkspaceVariableContribution as TheiaWorkspaceVariableContribution } f
import { WorkspaceVariableContribution } from './theia/workspace/workspace-variable-contribution';
import { DebugConfigurationManager } from './theia/debug/debug-configuration-manager';
import { DebugConfigurationManager as TheiaDebugConfigurationManager } from '@theia/debug/lib/browser/debug-configuration-manager';
import { SearchInWorkspaceWidget as TheiaSearchInWorkspaceWidget } from '@theia/search-in-workspace/lib/browser/search-in-workspace-widget';
import { SearchInWorkspaceWidget } from './theia/search-in-workspace/search-in-workspace-widget';
import { SearchInWorkspaceFactory as TheiaSearchInWorkspaceFactory } from '@theia/search-in-workspace/lib/browser/search-in-workspace-factory';
import { SearchInWorkspaceFactory } from './theia/search-in-workspace/search-in-workspace-factory';
import { SearchInWorkspaceResultTreeWidget as TheiaSearchInWorkspaceResultTreeWidget } from '@theia/search-in-workspace/lib/browser/search-in-workspace-result-tree-widget';
import { SearchInWorkspaceResultTreeWidget } from './theia/search-in-workspace/search-in-workspace-result-tree-widget';
import { MonacoEditorProvider } from './theia/monaco/monaco-editor-provider';
import {
MonacoEditorFactory,
@@ -605,9 +599,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
bind(MonacoEditorProvider).toSelf().inSingletonScope();
rebind(TheiaMonacoEditorProvider).toService(MonacoEditorProvider);
bind(SearchInWorkspaceWidget).toSelf();
rebind(TheiaSearchInWorkspaceWidget).toService(SearchInWorkspaceWidget);
// Disabled reference counter in the editor manager to avoid opening the same editor (with different opener options) multiple times.
bind(EditorManager).toSelf().inSingletonScope();
rebind(TheiaEditorManager).toService(EditorManager);
@@ -617,17 +608,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
.to(SearchInWorkspaceFactory)
.inSingletonScope();
rebind(TheiaSearchInWorkspaceResultTreeWidget).toDynamicValue(
({ container }) => {
const childContainer = createTreeContainer(container);
childContainer.bind(SearchInWorkspaceResultTreeWidget).toSelf();
childContainer
.rebind(TreeWidget)
.toService(SearchInWorkspaceResultTreeWidget);
return childContainer.get(SearchInWorkspaceResultTreeWidget);
}
);
// Show a disconnected status bar, when the daemon is not available
bind(ApplicationConnectionStatusContribution).toSelf().inSingletonScope();
rebind(TheiaApplicationConnectionStatusContribution).toService(

View File

@@ -259,9 +259,12 @@ export class BoardsConfig extends React.Component<
override render(): React.ReactNode {
return (
<>
{this.renderContainer('boards', this.renderBoards.bind(this))}
{this.renderContainer(
'ports',
nls.localize('arduino/board/boards', 'boards'),
this.renderBoards.bind(this)
)}
{this.renderContainer(
nls.localize('arduino/board/ports', 'ports'),
this.renderPorts.bind(this),
this.renderPortsFooter.bind(this)
)}
@@ -384,7 +387,9 @@ export class BoardsConfig extends React.Component<
defaultChecked={this.state.showAllPorts}
onChange={this.toggleFilterPorts}
/>
<span>Show all ports</span>
<span>
{nls.localize('arduino/board/showAllPorts', 'Show all ports')}
</span>
</label>
</div>
);

View File

@@ -5,7 +5,6 @@ import {
DisposableCollection,
Disposable,
} from '@theia/core/lib/common/disposable';
import { firstToUpperCase } from '../../common/utils';
import { BoardsConfig } from '../boards/boards-config';
import { MainMenuManager } from '../../common/main-menu-manager';
import { BoardsListWidget } from '../boards/boards-list-widget';
@@ -267,7 +266,11 @@ PID: ${PID}`;
];
const placeholder = new PlaceholderMenuNode(
menuPath,
`${firstToUpperCase(protocol)} ports`,
nls.localize(
'arduino/board/typeOfPorts',
'{0} ports',
Port.Protocols.protocolLabel(protocol)
),
{ order: protocolOrder.toString() }
);
this.menuModelRegistry.registerMenuNode(menuPath, placeholder);

View File

@@ -10,6 +10,7 @@ import { FileDialogService } from '@theia/filesystem/lib/browser/file-dialog/fil
import { DisposableCollection } from '@theia/core/lib/common/disposable';
import {
AdditionalUrls,
CompilerWarnings,
CompilerWarningLiterals,
Network,
ProxySettings,
@@ -260,7 +261,7 @@ export class SettingsComponent extends React.Component<
>
{CompilerWarningLiterals.map((value) => (
<option key={value} value={value}>
{value}
{CompilerWarnings.labelOf(value)}
</option>
))}
</select>
@@ -398,10 +399,22 @@ export class SettingsComponent extends React.Component<
</form>
<div className="flex-line proxy-settings">
<div className="column">
<div className="flex-line">Host name:</div>
<div className="flex-line">Port number:</div>
<div className="flex-line">Username:</div>
<div className="flex-line">Password:</div>
<div className="flex-line">{`${nls.localize(
'arduino/preferences/proxySettings/hostname',
'Host name'
)}:`}</div>
<div className="flex-line">{`${nls.localize(
'arduino/preferences/proxySettings/port',
'Port number'
)}:`}</div>
<div className="flex-line">{`${nls.localize(
'arduino/preferences/proxySettings/username',
'Username'
)}:`}</div>
<div className="flex-line">{`${nls.localize(
'arduino/preferences/proxySettings/password',
'Password'
)}:`}</div>
</div>
<div className="column stretch">
<div className="flex-line">

View File

@@ -18,6 +18,7 @@ import {
CLOSE_PLOTTER_WINDOW,
SHOW_PLOTTER_WINDOW,
} from '../../../common/ipc-communication';
import { nls } from '@theia/core/lib/common/nls';
const queryString = require('query-string');
@@ -107,7 +108,12 @@ export class PlotterFrontendContribution extends Contribution {
if (wsPort) {
this.open(wsPort);
} else {
this.messageService.error(`Couldn't open serial plotter`);
this.messageService.error(
nls.localize(
'arduino/contributions/plotter/couldNotOpen',
"Couldn't open serial plotter"
)
);
}
}

View File

@@ -111,13 +111,15 @@
font-weight: bold;
max-height: calc(1em + 4px);
color: var(--theia-button-foreground);
content: 'INSTALLED';
content: attr(install);
text-transform: uppercase;
}
.component-list-item .header .installed:hover:before {
background-color: var(--theia-button-foreground);
color: var(--theia-button-background);
content: 'UNINSTALL';
content: attr(uninstall);
text-transform: uppercase;
}
.component-list-item[min-width~="170px"] .footer {

View File

@@ -1,44 +0,0 @@
import { injectable } from '@theia/core/shared/inversify';
import URI from '@theia/core/lib/common/uri';
import {
SearchInWorkspaceFileNode,
SearchInWorkspaceResultTreeWidget as TheiaSearchInWorkspaceResultTreeWidget,
} from '@theia/search-in-workspace/lib/browser/search-in-workspace-result-tree-widget';
import { MEMORY_TEXT } from '@theia/core/lib/common/resource';
/**
* Workaround for https://github.com/eclipse-theia/theia/pull/9192/.
*/
@injectable()
export class SearchInWorkspaceResultTreeWidget extends TheiaSearchInWorkspaceResultTreeWidget {
protected override async createReplacePreview(
node: SearchInWorkspaceFileNode
): Promise<URI> {
const fileUri = new URI(node.fileUri).withScheme('file');
const openedEditor = this.editorManager.all.find(
({ editor }) => editor.uri.toString() === fileUri.toString()
);
let content: string;
if (openedEditor) {
content = openedEditor.editor.document.getText();
} else {
const resource = await this.fileResourceResolver.resolve(fileUri);
content = await resource.readContents();
}
const lines = content.split('\n');
node.children.map((l) => {
const leftPositionedNodes = node.children.filter(
(rl) => rl.line === l.line && rl.character < l.character
);
const diff =
(this._replaceTerm.length - this.searchTerm.length) *
leftPositionedNodes.length;
const start = lines[l.line - 1].substr(0, l.character - 1 + diff);
const end = lines[l.line - 1].substr(l.character - 1 + diff + l.length);
lines[l.line - 1] = start + this._replaceTerm + end;
});
return fileUri.withScheme(MEMORY_TEXT).withQuery(lines.join('\n'));
}
}

View File

@@ -1,80 +0,0 @@
import { injectable, postConstruct } from '@theia/core/shared/inversify';
import * as React from '@theia/core/shared/react';
import { Key, KeyCode } from '@theia/core/lib/browser';
import { SearchInWorkspaceWidget as TheiaSearchInWorkspaceWidget } from '@theia/search-in-workspace/lib/browser/search-in-workspace-widget';
/**
* Workaround for https://github.com/eclipse-theia/theia/pull/9183.
*/
@injectable()
export class SearchInWorkspaceWidget extends TheiaSearchInWorkspaceWidget {
@postConstruct()
protected override init(): void {
super.init();
this.title.iconClass = 'fa fa-arduino-search';
}
protected override renderGlobField(kind: 'include' | 'exclude'): React.ReactNode {
const currentValue = this.searchInWorkspaceOptions[kind];
const value = (currentValue && currentValue.join(', ')) || '';
return (
<div className="glob-field">
<div className="label">{'files to ' + kind}</div>
<input
className="theia-input"
type="text"
size={1}
defaultValue={value}
id={kind + '-glob-field'}
onKeyUp={(e) => {
if (e.target) {
const targetValue = (e.target as HTMLInputElement).value || '';
let shouldSearch =
Key.ENTER.keyCode ===
KeyCode.createKeyCode(e.nativeEvent).key?.keyCode;
const currentOptions = (this.searchInWorkspaceOptions[kind] || [])
.slice()
.map((s) => s.trim())
.sort();
const candidateOptions = this.splitOnComma(targetValue)
.map((s) => s.trim())
.sort();
const sameAs = (left: string[], right: string[]) => {
if (left.length !== right.length) {
return false;
}
for (let i = 0; i < left.length; i++) {
if (left[i] !== right[i]) {
return false;
}
}
return true;
};
if (!sameAs(currentOptions, candidateOptions)) {
this.searchInWorkspaceOptions[kind] =
this.splitOnComma(targetValue);
shouldSearch = true;
}
if (shouldSearch) {
this.resultTreeWidget.search(
this.searchTerm,
this.searchInWorkspaceOptions
);
}
}
}}
onFocus={
kind === 'include'
? this.handleFocusIncludesInputBox
: this.handleFocusExcludesInputBox
}
onBlur={
kind === 'include'
? this.handleBlurIncludesInputBox
: this.handleBlurExcludesInputBox
}
></input>
</div>
);
}
}

View File

@@ -55,7 +55,14 @@ export class ListItemRenderer<T extends ArduinoComponent> {
item.installedVersion
)}
</span>
<span className="installed" onClick={onClickUninstall} />
<span
className="installed"
onClick={onClickUninstall}
{...{
install: nls.localize('arduino/component/install', 'INSTALL'),
uninstall: nls.localize('arduino/component/uninstall', 'Uninstall'),
}}
/>
</div>
);

View File

@@ -285,6 +285,29 @@ export namespace Port {
return false;
};
}
export namespace Protocols {
export const KnownProtocolLiterals = ['serial', 'network'] as const;
export type KnownProtocol = typeof KnownProtocolLiterals[number];
export namespace KnownProtocol {
export function is(protocol: unknown): protocol is KnownProtocol {
return (
typeof protocol === 'string' &&
KnownProtocolLiterals.indexOf(protocol as KnownProtocol) >= 0
);
}
}
export const ProtocolLabels: Record<KnownProtocol, string> = {
serial: nls.localize('arduino/portProtocol/serial', 'Serial'),
network: nls.localize('arduino/portProtocol/network', 'Network'),
};
export function protocolLabel(protocol: string): string {
if (KnownProtocol.is(protocol)) {
return ProtocolLabels[protocol];
}
return protocol;
}
}
}
export interface BoardsPackage extends ArduinoComponent {

View File

@@ -1,3 +1,4 @@
import { nls } from '@theia/core/lib/common/nls';
import { ApplicationError } from '@theia/core/lib/common/application-error';
import type {
Location,
@@ -18,6 +19,17 @@ export const CompilerWarningLiterals = [
'All',
] as const;
export type CompilerWarnings = typeof CompilerWarningLiterals[number];
export namespace CompilerWarnings {
export function labelOf(warning: CompilerWarnings): string {
return CompilerWarningLabels[warning];
}
const CompilerWarningLabels: Record<CompilerWarnings, string> = {
None: nls.localize('arduino/core/compilerWarnings/none', 'None'),
Default: nls.localize('arduino/core/compilerWarnings/default', 'Default'),
More: nls.localize('arduino/core/compilerWarnings/more', 'More'),
All: nls.localize('arduino/core/compilerWarnings/all', 'All'),
};
}
export namespace CoreError {
export interface ErrorLocationRef {
readonly message: string;

View File

@@ -3,150 +3,45 @@ import {
LocalizationRegistry,
} from '@theia/core/lib/node/i18n/localization-contribution';
import { injectable } from '@theia/core/shared/inversify';
import { join } from 'path';
@injectable()
export class ArduinoLocalizationContribution
implements LocalizationContribution
{
// 0. index: locale
// 1. index: optional JSON file to `require` (if differs from the locale)
// If you touch the locales, please keep the alphabetical order. Also in the `package.json` for the VS Code language packs. Thank you! ❤️
// Note that IDE2 has more translations than available VS Code language packs. (https://github.com/arduino/arduino-ide/issues/1447)
private readonly locales: ReadonlyArray<[string, string?]> = [
['bg'],
['cs'],
['de'],
['es'],
['fr'],
['hu'],
// ['id'], Does not have Transifex translations, but has a VS Code language pack available on Open VSX.
['it'],
['ja'],
['ko'],
['nl'],
['pl'],
['pt-br', 'pt'],
['ru'],
['tr'],
['uk', 'uk_UA'],
['zh-cn', 'zh'],
];
async registerLocalizations(registry: LocalizationRegistry): Promise<void> {
registry.registerLocalizationFromRequire(
'af',
require('../../../build/i18n/af.json')
);
registry.registerLocalizationFromRequire(
'en',
require('../../../build/i18n/en.json')
);
registry.registerLocalizationFromRequire(
'fr',
require('../../../build/i18n/fr.json')
);
registry.registerLocalizationFromRequire(
'ko',
require('../../../build/i18n/ko.json')
);
registry.registerLocalizationFromRequire(
'pt-br',
require('../../../build/i18n/pt.json')
);
registry.registerLocalizationFromRequire(
'uk_UA',
require('../../../build/i18n/uk_UA.json')
);
registry.registerLocalizationFromRequire(
'ar',
require('../../../build/i18n/ar.json')
);
registry.registerLocalizationFromRequire(
'es',
require('../../../build/i18n/es.json')
);
registry.registerLocalizationFromRequire(
'he',
require('../../../build/i18n/he.json')
);
registry.registerLocalizationFromRequire(
'my_MM',
require('../../../build/i18n/my_MM.json')
);
registry.registerLocalizationFromRequire(
'ro',
require('../../../build/i18n/ro.json')
);
registry.registerLocalizationFromRequire(
'zh-cn',
require('../../../build/i18n/zh.json')
);
registry.registerLocalizationFromRequire(
'bg',
require('../../../build/i18n/bg.json')
);
registry.registerLocalizationFromRequire(
'eu',
require('../../../build/i18n/eu.json')
);
registry.registerLocalizationFromRequire(
'hu',
require('../../../build/i18n/hu.json')
);
registry.registerLocalizationFromRequire(
'ne',
require('../../../build/i18n/ne.json')
);
registry.registerLocalizationFromRequire(
'ru',
require('../../../build/i18n/ru.json')
);
registry.registerLocalizationFromRequire(
'zh_TW',
require('../../../build/i18n/zh_TW.json')
);
registry.registerLocalizationFromRequire(
'de',
require('../../../build/i18n/de.json')
);
registry.registerLocalizationFromRequire(
'fa',
require('../../../build/i18n/fa.json')
);
registry.registerLocalizationFromRequire(
'it',
require('../../../build/i18n/it.json')
);
registry.registerLocalizationFromRequire(
'nl',
require('../../../build/i18n/nl.json')
);
registry.registerLocalizationFromRequire(
'sv_SE',
require('../../../build/i18n/sv_SE.json')
);
registry.registerLocalizationFromRequire(
'el',
require('../../../build/i18n/el.json')
);
registry.registerLocalizationFromRequire(
'fil',
require('../../../build/i18n/fil.json')
);
registry.registerLocalizationFromRequire(
'ja',
require('../../../build/i18n/ja.json')
);
registry.registerLocalizationFromRequire(
'pl',
require('../../../build/i18n/pl.json')
);
registry.registerLocalizationFromRequire(
'tr',
require('../../../build/i18n/tr.json')
);
for (const [locale, jsonFilename] of this.locales) {
registry.registerLocalizationFromRequire(
locale,
require(join(
__dirname,
`../../../build/i18n/${jsonFilename ?? locale}.json`
))
);
}
}
}

View File

@@ -23,8 +23,8 @@ export class LocalizationBackendContribution extends TheiaLocalizationBackendCon
app.get('/i18n/:locale', async (req, res) => {
let locale = req.params.locale;
/*
Waiting for the deploy of the language plugins is neecessary to avoid checking the available
languages before they're finished to be loaded: https://github.com/eclipse-theia/theia/issues/11471
Waiting for the deploy of the language plugins is necessary to avoid checking the available
languages before they're finished to be loaded: https://github.com/eclipse-theia/theia/issues/11471
*/
const start = performance.now();
await this.initialized.promise;