Skip to content

Commit ecef208

Browse files
author
Akos Kitta
committed
Translate search option props.
Signed-off-by: Akos Kitta <[email protected]>
1 parent 0325182 commit ecef208

File tree

5 files changed

+43
-8
lines changed

5 files changed

+43
-8
lines changed

arduino-ide-extension/src/browser/widgets/component-list/filter-renderer.tsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
LibrarySearch,
66
Searchable,
77
} from '../../../common/protocol';
8-
import { firstToUpperCase } from '../../../common/utils';
98

109
@injectable()
1110
export abstract class FilterRenderer<S extends Searchable.Options> {
@@ -20,8 +19,7 @@ export abstract class FilterRenderer<S extends Searchable.Options> {
2019
.filter(([prop]) => props.includes(prop as keyof S))
2120
.map(([prop, value]) => (
2221
<div key={prop}>
23-
{/* TODO: translations? */}
24-
{firstToUpperCase(prop)}:
22+
{this.propertyLabel(prop as keyof S)}:
2523
<select
2624
className="theia-select"
2725
value={value}
@@ -32,7 +30,7 @@ export abstract class FilterRenderer<S extends Searchable.Options> {
3230
>
3331
{this.options(prop as keyof S).map((key) => (
3432
<option key={key} value={key}>
35-
{this.label(prop as keyof S, key)}
33+
{this.valueLabel(prop as keyof S, key)}
3634
</option>
3735
))}
3836
</select>
@@ -43,7 +41,8 @@ export abstract class FilterRenderer<S extends Searchable.Options> {
4341
}
4442
protected abstract props(): (keyof S)[];
4543
protected abstract options(prop: keyof S): string[];
46-
protected abstract label(prop: keyof S, key: string): string;
44+
protected abstract valueLabel(prop: keyof S, key: string): string;
45+
protected abstract propertyLabel(prop: keyof S): string;
4746
}
4847

4948
@injectable()
@@ -60,7 +59,7 @@ export class BoardsFilterRenderer extends FilterRenderer<BoardSearch> {
6059
throw new Error(`Unexpected prop: ${prop}`);
6160
}
6261
}
63-
protected label(prop: keyof BoardSearch, key: string): string {
62+
protected valueLabel(prop: keyof BoardSearch, key: string): string {
6463
switch (prop) {
6564
case 'type':
6665
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -69,6 +68,14 @@ export class BoardsFilterRenderer extends FilterRenderer<BoardSearch> {
6968
throw new Error(`Unexpected key: ${prop}`);
7069
}
7170
}
71+
protected propertyLabel(prop: keyof BoardSearch): string {
72+
switch (prop) {
73+
case 'type':
74+
return BoardSearch.PropertyLabels[prop];
75+
default:
76+
throw new Error(`Unexpected key: ${prop}`);
77+
}
78+
}
7279
}
7380

7481
@injectable()
@@ -88,7 +95,16 @@ export class LibraryFilterRenderer extends FilterRenderer<LibrarySearch> {
8895
throw new Error(`Unexpected prop: ${prop}`);
8996
}
9097
}
91-
protected label(prop: keyof LibrarySearch, key: string): string {
98+
protected propertyLabel(prop: keyof LibrarySearch): string {
99+
switch (prop) {
100+
case 'type':
101+
case 'topic':
102+
return LibrarySearch.PropertyLabels[prop];
103+
default:
104+
throw new Error(`Unexpected key: ${prop}`);
105+
}
106+
}
107+
protected valueLabel(prop: keyof LibrarySearch, key: string): string {
92108
switch (prop) {
93109
case 'type':
94110
// eslint-disable-next-line @typescript-eslint/no-explicit-any

arduino-ide-extension/src/common/nls.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const Unknown = nls.localize('arduino/common/unknown', 'Unknown');
44
export const Later = nls.localize('arduino/common/later', 'Later');
55
export const Updatable = nls.localize('arduino/common/updateable', 'Updatable');
66
export const All = nls.localize('arduino/common/all', 'All');
7+
export const Type = nls.localize('arduino/common/type', 'Type');
78
export const Partner = nls.localize('arduino/common/partner', 'Partner');
89
export const Contributed = nls.localize(
910
'arduino/common/contributed',

arduino-ide-extension/src/common/protocol/boards-service.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Searchable } from './searchable';
33
import { Installable } from './installable';
44
import { ArduinoComponent } from './arduino-component';
55
import { nls } from '@theia/core/lib/common/nls';
6-
import { All, Contributed, Partner, Updatable } from '../nls';
6+
import { All, Contributed, Partner, Type, Updatable } from '../nls';
77

88
export type AvailablePorts = Record<string, [Port, Array<Board>]>;
99
export namespace AvailablePorts {
@@ -173,6 +173,12 @@ export namespace BoardSearch {
173173
Partner: Partner,
174174
'Arduino@Heart': 'Arduino@Heart',
175175
};
176+
export const PropertyLabels: Record<
177+
keyof Omit<BoardSearch, 'query'>,
178+
string
179+
> = {
180+
type: Type,
181+
};
176182
}
177183

178184
export interface Port {

arduino-ide-extension/src/common/protocol/library-service.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
Partner,
99
Recommended,
1010
Retired,
11+
Type,
1112
Updatable,
1213
} from '../nls';
1314

@@ -119,6 +120,13 @@ export namespace LibrarySearch {
119120
'Uncategorized'
120121
),
121122
};
123+
export const PropertyLabels: Record<
124+
keyof Omit<LibrarySearch, 'query'>,
125+
string
126+
> = {
127+
topic: nls.localize('arduino/librarySearchProperty/topic', 'Topic'),
128+
type: Type,
129+
};
122130
}
123131

124132
export namespace LibraryService {

i18n/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
"retired": "Retired",
127127
"selectedOn": "on {0}",
128128
"serialMonitor": "Serial Monitor",
129+
"type": "Type",
129130
"unknown": "Unknown",
130131
"updateable": "Updatable"
131132
},
@@ -251,6 +252,9 @@
251252
"uninstalledSuccessfully": "Successfully uninstalled library {0}:{1}",
252253
"zipLibrary": "Library"
253254
},
255+
"librarySearchProperty": {
256+
"topic": "Topic"
257+
},
254258
"libraryTopic": {
255259
"communication": "Communication",
256260
"dataProcessing": "Data Processing",

0 commit comments

Comments
 (0)