Skip to content

Commit 8687c90

Browse files
committed
backend intl
1 parent 3a231d5 commit 8687c90

File tree

16 files changed

+81
-88
lines changed

16 files changed

+81
-88
lines changed

packages/selenium-ide/src/browser/I18N/en/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ const testCoreEnglish = {
196196
playFromStart: 'Play From Start',
197197
}
198198

199-
export const langaugeMapEn = {
199+
export const backend = {
200200
windowTab: windowTabEnglish,
201201
electronMenuTree: electronMenuTreeEnglish,
202202
fileMenuTree: fileMenuTreeEnglish,
@@ -218,7 +218,6 @@ export const langaugeMapEn = {
218218

219219
// Creating a type of this so other locales are prompted to be filled in by
220220
// the developer
221-
export type LanguageMap = typeof langaugeMapEn
221+
export type LanguageMap = typeof backend
222222

223-
const flattenedMap = flattenNestedObject(langaugeMapEn)
224-
export default flattenedMap
223+
export const frontend = flattenNestedObject(backend)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {langaugeMapEn} from './en'
1+
import {backend} from './en'
22
import {transformNestedObject} from './util'
33

44
/**
55
* Take this nested object, keep the shape, but make the final keys the dot delimited string
66
* path of the nested key
77
*/
8-
const languageMap = transformNestedObject((key) => key, langaugeMapEn)
8+
const languageMap = transformNestedObject((key) => key, backend)
99

1010
export default languageMap

packages/selenium-ide/src/browser/I18N/zh/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { LanguageMap } from '../en/index'
22
import Commands from '@seleniumhq/side-model/dist/I18N/zh/Commands'
3-
import {transformNestedObject} from '../util'
3+
import { transformNestedObject } from '../util'
44

55
// 窗口顶部菜单
66
const windowTabChinese = {
@@ -202,7 +202,7 @@ const testCoreChinese = {
202202
playFromStart: '从头开始回放',
203203
}
204204

205-
export const languageMapZh: LanguageMap = {
205+
export const backend: LanguageMap = {
206206
windowTab: windowTabChinese,
207207
electronMenuTree: electronMenuTreeChinese,
208208
fileMenuTree: fileMenuTreeChinese,
@@ -222,4 +222,4 @@ export const languageMapZh: LanguageMap = {
222222
commandMap: Commands,
223223
}
224224

225-
export default transformNestedObject((_k, v) => v, languageMapZh)
225+
export const frontend = transformNestedObject((_k, v) => v, backend)

packages/selenium-ide/src/browser/windows/ProjectEditor/tabs/Tests/CommandFields/TextField.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ import { LocatorFields } from '@seleniumhq/side-api'
1010
import { useIntl } from 'react-intl'
1111
import languageMap from 'browser/I18N/keys'
1212

13+
const inputLabelProps = {
14+
sx: {
15+
textOverflow: 'ellipsis',
16+
},
17+
}
18+
1319
const CommandTextField: FC<CommandFieldProps> = ({
1420
command,
1521
disabled,
@@ -33,12 +39,16 @@ const CommandTextField: FC<CommandFieldProps> = ({
3339
return value
3440
}
3541
}
42+
console.log(
43+
languageMap.commandMap[command.command][fieldName as LocatorFields]
44+
?.description,
45+
command
46+
)
3647
// 一定会使用languageMap.commandMap,其实是为了兼容参数commands
3748
const fullNote =
3849
note ||
3950
intl.formatMessage({
40-
id: languageMap.commandMap[command.command][fieldName as LocatorFields]
41-
?.description,
51+
id: `commandMap.${command.command}.${fieldName}.description`,
4252
})
4353
const label = fullNote
4454
? handleLabel(FieldName) + ' - ' + fullNote
@@ -51,11 +61,7 @@ const CommandTextField: FC<CommandFieldProps> = ({
5161
disabled={disabled}
5262
id={`${fieldName}-${command.id}`}
5363
label={label}
54-
InputLabelProps={{
55-
sx: {
56-
textOverflow: 'ellipsis',
57-
},
58-
}}
64+
InputLabelProps={inputLabelProps}
5965
name={fieldName}
6066
onChange={updateText(testID, command.id)}
6167
onContextMenu={() => {

packages/selenium-ide/src/browser/windows/ProjectEditor/tabs/Tests/TestsDrawer.tsx

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { context as testsContext } from 'browser/contexts/tests'
1515
import { context as testResultsContext } from 'browser/contexts/playback-test-results'
1616
import { FormattedMessage, useIntl } from 'react-intl'
1717
import languageMap from 'browser/I18N/keys'
18+
import { QuestionAnswer } from '@mui/icons-material'
1819

1920
const {
2021
state: { setActiveTest: setSelected, setActiveSuite },
@@ -60,7 +61,13 @@ const TestsDrawer: FC = () => {
6061
)
6162
}
6263
}
63-
/>
64+
>
65+
<Tooltip
66+
title={<FormattedMessage id={languageMap.testsTab.tooltip} />}
67+
>
68+
<QuestionAnswer />
69+
</Tooltip>
70+
</EditorToolbar>
6471
<FormControl size="small">
6572
<Select
6673
MenuProps={{
@@ -96,22 +103,17 @@ const TestsDrawer: FC = () => {
96103
.map(({ id, name }) => {
97104
const testState = testResults[id]?.state
98105
return (
99-
<Tooltip
100-
title={<FormattedMessage id={languageMap.testsTab.tooltip} />}
101-
>
102-
<RenamableListItem
103-
id={id}
104-
key={id}
105-
name={name}
106-
onContextMenu={() => {
107-
window.sideAPI.menus.open('testManager', [id])
108-
}}
109-
rename={rename}
110-
selected={id === activeTestID}
111-
setSelected={setSelected}
112-
state={testState}
113-
/>
114-
</Tooltip>
106+
<RenamableListItem
107+
id={id}
108+
name={name}
109+
onContextMenu={() => {
110+
window.sideAPI.menus.open('testManager', [id])
111+
}}
112+
rename={rename}
113+
selected={id === activeTestID}
114+
setSelected={setSelected}
115+
state={testState}
116+
/>
115117
)
116118
})}
117119
</List>

packages/selenium-ide/src/main/session/controllers/Menu/menus/application.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,54 +13,54 @@ export const commands: MenuComponent = (session: Session) => () =>
1313
label: 'Selenium IDE',
1414
submenu: [
1515
{
16-
label: session.store.get('languageMap').electronMenuTree.about,
16+
label: session.system.languageMap.electronMenuTree.about,
1717
role: 'about',
1818
},
1919
{ type: 'separator' },
2020
{
21-
label: session.store.get('languageMap').electronMenuTree.services,
21+
label: session.system.languageMap.electronMenuTree.services,
2222
role: 'services',
2323
},
2424
{ type: 'separator' },
2525
{
26-
label: session.store.get('languageMap').electronMenuTree.hideElectron,
26+
label: session.system.languageMap.electronMenuTree.hideElectron,
2727
role: 'hide',
2828
},
2929
{
30-
label: session.store.get('languageMap').electronMenuTree.hideOthers,
30+
label: session.system.languageMap.electronMenuTree.hideOthers,
3131
role: 'hideOthers',
3232
},
3333
{
34-
label: session.store.get('languageMap').electronMenuTree.showAll,
34+
label: session.system.languageMap.electronMenuTree.showAll,
3535
role: 'unhide',
3636
},
3737
{ type: 'separator' },
3838
{
3939
accelerator: platform() === 'win32' ? 'Alt+F4' : 'CommandOrControl+Q',
40-
label: session.store.get('languageMap').electronMenuTree.quit,
40+
label: session.system.languageMap.electronMenuTree.quit,
4141
click: async () => {
4242
await session.system.quit()
4343
},
4444
},
4545
],
4646
},
4747
{
48-
label: session.store.get('languageMap').windowTab.file,
48+
label: session.system.languageMap.windowTab.file,
4949
submenu: projectEditorCommands(session)(),
5050
},
5151
{
52-
label: session.store.get('languageMap').windowTab.edit,
52+
label: session.system.languageMap.windowTab.edit,
5353
submenu: [
5454
...editBasicsCommands(session)(),
5555
...testEditorCommands(session)(),
5656
],
5757
},
5858
{
59-
label: session.store.get('languageMap').windowTab.view,
59+
label: session.system.languageMap.windowTab.view,
6060
submenu: projectViewCommands(session)(),
6161
},
6262
{
63-
label: session.store.get('languageMap').windowTab.help,
63+
label: session.system.languageMap.windowTab.help,
6464
submenu: helpMenuCommands(session)(),
6565
},
6666
]

packages/selenium-ide/src/main/session/controllers/Menu/menus/editBasics.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ export const commands: MenuComponent = (session) => () =>
77
accelerator: 'CommandOrControl+Z',
88
click: () => session.api.state.undo(),
99
enabled: session.state.prevHistory.length !== 0,
10-
label: session.store.get('languageMap').editMenuTree.undo,
10+
label: session.system.languageMap.editMenuTree.undo,
1111
},
1212
{
1313
accelerator: 'CommandOrControl+Shift+Z',
1414
click: () => session.api.state.redo(),
1515
enabled: session.state.nextHistory.length !== 0,
16-
label: session.store.get('languageMap').editMenuTree.redo,
16+
label: session.system.languageMap.editMenuTree.redo,
1717
},
1818
{ type: 'separator' },
19-
{ label: session.store.get('languageMap').editMenuTree.cut, role: 'cut' },
20-
{ label: session.store.get('languageMap').editMenuTree.copy, role: 'copy' },
19+
{ label: session.system.languageMap.editMenuTree.cut, role: 'cut' },
20+
{ label: session.system.languageMap.editMenuTree.copy, role: 'copy' },
2121
{
22-
label: session.store.get('languageMap').editMenuTree.paste,
22+
label: session.system.languageMap.editMenuTree.paste,
2323
role: 'paste',
2424
},
2525
]

packages/selenium-ide/src/main/session/controllers/Menu/menus/help.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const commands: MenuComponent = (session) => () =>
88
click: async () => {
99
await session.system.dumpSession()
1010
},
11-
label: session.store.get('languageMap').helpMenuTree.dumpSession,
11+
label: session.system.languageMap.helpMenuTree.dumpSession,
1212
},
1313
]
1414

packages/selenium-ide/src/main/session/controllers/Menu/menus/projectEditor.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ export const commands: MenuComponent = (session) => () =>
55
[
66
{
77
accelerator: 'CommandOrControl+N',
8-
label: session.store.get('languageMap').fileMenuTree.newProject,
8+
label: session.system.languageMap.fileMenuTree.newProject,
99
click: async () => {
1010
await session.api.projects.new()
1111
},
1212
},
1313
{ type: 'separator' },
1414
{
1515
accelerator: 'CommandOrControl+O',
16-
label: session.store.get('languageMap').fileMenuTree.loadProject,
16+
label: session.system.languageMap.fileMenuTree.loadProject,
1717
click: async () => {
1818
const response = await session.dialogs.open()
1919
if (response.canceled) return
@@ -22,7 +22,7 @@ export const commands: MenuComponent = (session) => () =>
2222
},
2323
{
2424
accelerator: 'CommandOrControl+R',
25-
label: session.store.get('languageMap').fileMenuTree.recentProjects,
25+
label: session.system.languageMap.fileMenuTree.recentProjects,
2626
click: async () => {
2727
await session.projects.showRecents()
2828
},
@@ -36,15 +36,15 @@ export const commands: MenuComponent = (session) => () =>
3636
{ type: 'separator' },
3737
{
3838
accelerator: 'CommandOrControl+S',
39-
label: session.store.get('languageMap').fileMenuTree.saveProject,
39+
label: session.system.languageMap.fileMenuTree.saveProject,
4040
click: async () => {
4141
await session.projects.save(session.projects.filepath as string)
4242
},
4343
enabled: Boolean(session.projects.filepath),
4444
},
4545
{
4646
accelerator: 'CommandOrControl+Shift+S',
47-
label: session.store.get('languageMap').fileMenuTree.saveProjectAs,
47+
label: session.system.languageMap.fileMenuTree.saveProjectAs,
4848
click: async () => {
4949
const response = await session.dialogs.openSave()
5050
if (response.canceled) return

packages/selenium-ide/src/main/session/controllers/Menu/menus/projectView.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ export const commands: MenuComponent = (session) => () =>
1515
const window = BrowserWindow.getFocusedWindow()
1616
window?.webContents.openDevTools()
1717
},
18-
label: session.store.get('languageMap').viewMenuTree.showDevTools,
18+
label: session.system.languageMap.viewMenuTree.showDevTools,
1919
}
2020
),
2121
{
2222
accelerator: 'CommandOrControl+P',
2323
click: async () => {
2424
await session.windows.initializePlaybackWindow()
2525
},
26-
label: session.store.get('languageMap').viewMenuTree.resetPlaybackWindows,
26+
label: session.system.languageMap.viewMenuTree.resetPlaybackWindows,
2727
},
2828
{
2929
accelerator: 'CommandOrControl+R',
30-
label: session.store.get('languageMap').viewMenuTree.refreshPlaybackWindow,
30+
label: session.system.languageMap.viewMenuTree.refreshPlaybackWindow,
3131
click: async () => {
3232
const window = await session.windows.getActivePlaybackWindow()
3333
if (window) {

0 commit comments

Comments
 (0)