Skip to content

Commit 7058b27

Browse files
committed
localize type names and add react-common to strings
1 parent 3c1e395 commit 7058b27

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

cli/cli.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,6 +1830,9 @@ function saveThemeJson(cfg: pxt.TargetBundle, localDir?: boolean, packaged?: boo
18301830
if (extraType.label) {
18311831
targetStrings[`{id:type}${extraType.label}`] = extraType.label;
18321832
}
1833+
else {
1834+
targetStrings[`{id:type}${extraType.typeName}`] = extraType.typeName;
1835+
}
18331836

18341837
if (extraType.defaultName) {
18351838
targetStrings[`{id:var}${extraType.defaultName}`] = extraType.defaultName;

gulpfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ function updatestrings() {
235235
"pxtpy",
236236
"pxtsim",
237237
"webapp/src",
238+
"react-common"
238239
], true);
239240
}
240241

webapp/src/createFunction.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,18 +212,19 @@ export class CreateFunctionDialog extends data.Component<ISettingsProps, CreateF
212212
}
213213
];
214214

215-
if (pxt.appTarget.runtime &&
216-
pxt.appTarget.runtime.functionsOptions &&
217-
pxt.appTarget.runtime.functionsOptions.extraFunctionEditorTypes &&
218-
Array.isArray(pxt.appTarget.runtime.functionsOptions.extraFunctionEditorTypes)) {
215+
const extraTypes = pxt.appTarget.runtime?.functionsOptions?.extraFunctionEditorTypes;
216+
217+
if (Array.isArray(extraTypes)) {
218+
for (const extraType of extraTypes) {
219+
const label = extraType.label || extraType.typeName;
220+
const defaultName = extraType.defaultName;
219221

220-
pxt.appTarget.runtime.functionsOptions.extraFunctionEditorTypes.forEach(t => {
221222
types.push({
222-
...t,
223-
label: t.label && pxt.Util.rlf(`{id:type}${t.label}`),
224-
defaultName: t.defaultName && pxt.Util.rlf(`{id:var}${t.defaultName}`)
225-
})
226-
});
223+
...extraType,
224+
label: pxt.Util.rlf(`{id:type}${label}`),
225+
defaultName: defaultName && pxt.Util.rlf(`{id:var}${defaultName}`)
226+
});
227+
}
227228
}
228229

229230
types.forEach(t => {

0 commit comments

Comments
 (0)