Skip to content

Commit

Permalink
ensuring the localization detonates without zh equivalents
Browse files Browse the repository at this point in the history
  • Loading branch information
toddtarsi committed Apr 28, 2024
1 parent 6d5590a commit 84c13cf
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 97 deletions.
88 changes: 44 additions & 44 deletions packages/selenium-ide/src/browser/I18N/en/index.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
import { Commands as commandMapEnglish } from '@seleniumhq/side-model'
import { flattenNestedObject } from '../util'
import { Commands as commandMap } from '@seleniumhq/side-model'

const windowTabEnglish = {
const windowTab = {
file: '&File',
edit: '&Edit',
view: '&View',
help: '&Help',
title: 'Project Editor',
}

const electronMenuTreeEnglish = {
const electronMenuTree = {
about: 'About Electron',
services: 'Services',
hideElectron: 'Hide Electron',
hideOthers: 'Hide Others',
showAll: 'Show All',
quit: 'Quit',
newString: 'how this?',
}

const fileMenuTreeEnglish = {
const fileMenuTree = {
newProject: 'New Project',
loadProject: 'Load Project',
recentProjects: 'Recent Projects',
saveProject: 'Save Project',
saveProjectAs: 'Save Project As...',
}

const editMenuTreeEnglish = {
const editMenuTree = {
undo: 'Undo (for input)',
redo: 'Redo (for input)',
cut: 'Cut (for input)',
copy: 'Copy (for input)',
paste: 'Paste (for input)',
}

const viewMenuTreeEnglish = {
const viewMenuTree = {
showDevTools: 'Show DevTools',
resetPlaybackWindows: 'Reset Playback Windows',
refreshPlaybackWindow: 'Refresh Playback Window',
}

const helpMenuTreeEnglish = {
const helpMenuTree = {
dumpSession: 'Dump Session To File',
}

const mainMenuEnglish = { tests: 'Tests', suites: 'Suites', config: 'Config' }
const mainMenu = { tests: 'Tests', suites: 'Suites', config: 'Config' }

const configTabEnglish = {
const configTab = {
project: 'Project',
system: 'System',
outPut: 'outPut',
}

const outPutConfigEnglish = {
const outPutConfig = {
webLink: 'click to jump to the testing platform',
platformUrl: 'test platform address',
platformUrlHelper: 'The final use case is displayed on this front-end page',
Expand All @@ -79,7 +79,7 @@ const outPutConfigEnglish = {
failMessage: 'please contact the backend developer for assistance!',
}

const systemConfigEnglish = {
const systemConfig = {
theme: 'Theme preference',
themeHelper: 'restart required to take effect',
commandInsert: 'New command insert preference',
Expand All @@ -92,7 +92,7 @@ const systemConfigEnglish = {
restartDriver: 'restart driver',
}

const projectConfigEnglish = {
const projectConfig = {
name: 'name',
stepTimeout: 'Step Timeout (MILLISECONDS)',
stepTimeoutHelper: 'Steps will fail if they take longer than this setting',
Expand All @@ -101,7 +101,7 @@ const projectConfigEnglish = {
projectPlugins: 'Project Plugins',
}

const suitesTabEnglish = {
const suitesTab = {
testInSuite: 'Tests in suite',
dropTests: 'Drop Tests Here',
AvailableTests: 'Available tests',
Expand All @@ -115,19 +115,19 @@ const suitesTabEnglish = {
create: 'Create',
deleteNotice: 'Are you sure you want to delete suite {name}?',
tooltip:
'double click to modify the name,right click to export or delete suites',
notDeleteNotice: 'only one suites is not allowed to be deleted!',
'Double click to modify the name.\nRight click to export or delete suites',
notDeleteNotice: 'If only one suite is left, it is not allowed to be deleted',
noSuiteSelected: 'No Suite Selected',
playSuite: 'Play Suite',
deleteSuite: 'Delete suite(s)',
exportSuite: 'Export suite(s) to ',
}

const testsTabEnglish = {
const testsTab = {
allTests: '[All tests]',
deleteNotice: 'Delete this test?',
tooltip:
'double click to modify the name,right click to export or delete test case',
'Double click to modify the name,\nRight click to export or delete test case',
notDeleteNotice: 'only one test case is not allowed to be deleted!',
dialogTitle: 'Please specify the new test name',
testName: 'Test Name',
Expand All @@ -141,7 +141,7 @@ const testsTabEnglish = {
exportTest: 'Export test(s) to ',
}

const playbackEnglish = {
const playback = {
content: 'This is where recording and playback will occur',
windowSize:
'Force panel window dimensions (will zoom out if larger than panel and crop if smaller)',
Expand All @@ -150,18 +150,18 @@ const playbackEnglish = {
url: 'URL',
}

const splashEnglish = {
const splash = {
present: 'Welcome to the Selenium IDE client',
logPath: 'Your log file path:',
openNotice: 'You can load or create one project',
loadProject: 'load project',
createProject: 'create project',
openRecent: 'open recent',
loadProject: 'Load Project',
createProject: 'Create Project',
openRecent: 'Recent Projects',
languageSelect: 'choose language',
}

// 用例编辑页面
const testCoreEnglish = {
const testCore = {
play: 'Play',
stop: 'Stop',
record: 'Record',
Expand Down Expand Up @@ -196,28 +196,28 @@ const testCoreEnglish = {
playFromStart: 'Play From Start',
}

export const backend = {
windowTab: windowTabEnglish,
electronMenuTree: electronMenuTreeEnglish,
fileMenuTree: fileMenuTreeEnglish,
editMenuTree: editMenuTreeEnglish,
viewMenuTree: viewMenuTreeEnglish,
helpMenuTree: helpMenuTreeEnglish,
mainMenu: mainMenuEnglish,
testsTab: testsTabEnglish,
suitesTab: suitesTabEnglish,
configTab: configTabEnglish,
systemConfig: systemConfigEnglish,
projectConfig: projectConfigEnglish,
outPutConfig: outPutConfigEnglish,
splash: splashEnglish,
playback: playbackEnglish,
testCore: testCoreEnglish,
commandMap: commandMapEnglish,
export const language = {
windowTab,
electronMenuTree,
fileMenuTree,
editMenuTree,
viewMenuTree,
helpMenuTree,
mainMenu,
testsTab,
suitesTab,
configTab,
systemConfig,
projectConfig,
outPutConfig,
splash,
playback,
testCore,
commandMap,
}

// Creating a type of this so other locales are prompted to be filled in by
// the developer
export type LanguageMap = typeof backend
export type LanguageMap = typeof language

export const frontend = flattenNestedObject(backend)
export default language
4 changes: 2 additions & 2 deletions packages/selenium-ide/src/browser/I18N/keys.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {backend} from './en'
import en from './en'
import {transformNestedObject} from './util'

/**
* Take this nested object, keep the shape, but make the final keys the dot delimited string
* path of the nested key
*/
const languageMap = transformNestedObject((key) => key, backend)
const languageMap = transformNestedObject((key) => key, en)

export default languageMap
4 changes: 2 additions & 2 deletions packages/selenium-ide/src/browser/I18N/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const processOneLevel = <T extends RecursiveShape>(
prefix: string,
getValue: (key: string, value: string) => any,
obj: T
): Record<string, any> => {
): T => {
return Object.entries(obj).reduce((acc, [key, value]) => {
const keyPath = prefix ? `${prefix}.${key}` : key
if (value && typeof value === 'object') {
Expand All @@ -28,7 +28,7 @@ const processOneLevel = <T extends RecursiveShape>(
export const transformNestedObject = <T extends RecursiveShape>(
getValue: (key: string, value: string) => any,
obj: T
): Record<string, any> => processOneLevel<T>('', getValue, obj)
): T => processOneLevel<T>('', getValue, obj)

const flattenOneLevel = <T extends RecursiveShape>(
prefix: string,
Expand Down
Loading

0 comments on commit 84c13cf

Please sign in to comment.