From fc6c1f0d79c742788a6e8251ef793725aa51f469 Mon Sep 17 00:00:00 2001 From: Katherine Jensen Date: Fri, 6 Sep 2024 05:10:37 -0700 Subject: [PATCH] Alphabetize and create more specific localize keys --- assets/localization/en.json | 132 +++++++++--------- assets/localization/fr.json | 2 +- .../contributions/localizedStrings.json | 4 +- .../src/hello-world/contributions/menus.json | 2 +- .../src/web-views/hello-world.web-view.tsx | 2 +- .../src/platform-scripture-editor/src/main.ts | 18 ++- .../contextMenu.component.onClick.test.tsx | 2 +- ...contextMenu.component.open.render.test.tsx | 2 +- .../mui/gridMenu.component.render.test.tsx | 6 +- .../mui/sample.composed.full.menu.json | 14 +- .../data/core-project-settings-info.data.ts | 16 +-- .../data/core-settings-info.data.ts | 10 +- src/extension-host/data/menu.data.json | 32 ++--- .../localization.service-host.test.ts | 30 ++-- .../services/menu-data.service-host.test.tsx | 14 +- .../project-settings.service-host.test.ts | 6 +- .../services/settings.service-host.test.ts | 4 +- .../dialogs/select-books-dialog.component.tsx | 2 +- .../select-multiple-projects.dialog.tsx | 2 +- .../dialogs/select-project.dialog.tsx | 2 +- .../docking/error-tab.component.tsx | 2 +- .../docking/platform-tab-title.component.tsx | 2 +- .../book-selector.component.tsx | 10 +- .../run-basic-checks-tab.component.tsx | 49 +++---- .../settings-components/setting.component.tsx | 2 +- .../settings-tabs/settings-tab.component.tsx | 8 +- .../components/web-view.component.tsx | 19 ++- src/shared/models/docking-framework.model.ts | 5 +- src/shared/models/web-view.model.ts | 5 +- .../utils/menu-document-combiner.test.ts | 28 ++-- ...project-settings-document-combiner.test.ts | 10 +- .../utils/settings-document-combiner.test.ts | 4 +- 32 files changed, 233 insertions(+), 213 deletions(-) diff --git a/assets/localization/en.json b/assets/localization/en.json index 472c7f7831..0d5f3dbbcc 100644 --- a/assets/localization/en.json +++ b/assets/localization/en.json @@ -1,79 +1,79 @@ { - "%product_name%": "Platform.Bible", - "%bookSelector_chooseEllipsis%": "Choose...", - "%bookSelector_chooseBooks%": "Choose Books", - "%bookSelector_currentBook%": "Current Book", - "%bookSelector_selectBooks%": "Select Books", - "%bookSelector_selectOneOrMoreBooksToRunBasicChecksOn%": "Select one or more books to run basic checks on", - "%checks_Capitalization%": "Capitalization", - "%checks_chapterSlashVerseNumbers%": "Chapter/Verse Numbers", - "%checks_charactersParenthesesCombinations%": "Characters (Combinations)", - "%checks_checks%": "Checks", - "%checks_footnoteQuotes%": "Footnote Quotes", - "%checks_markers%": "Markers", - "%checks_noCurrentProject%": "No current project", - "%checks_numbers%": "Numbers", - "%checks_punctuationParenthesesSequences%": "Punctuation (Sequences)", - "%checks_quotations%": "Quotations", - "%checks_quotationTypes%": "Quotation types", - "%checks_references%": "References", - "%checks_repeatedWords%": "Repeated Words", - "%checks_runBasicChecks%": "Run Basic Checks", - "%checks_unmatchedPairsOfPunctuation%": "Unmatched Pairs of Punctuation", + "%bookSelector_dialogPrompt_selectOneOrMoreBooksToRunBasicChecksOn%": "Select one or more books to run basic checks on", + "%bookSelector_selectionMode_chooseBooks%": "Choose Books", + "%bookSelector_selectionMode_currentBook%": "Current Book", + "%bookSelector_submitButton_chooseEllipsis%": "Choose...", + "%bookSelector_title_selectBooks%": "Select Books", + "%checks_checkName_capitalization%": "Capitalization", + "%checks_checkName_chapterSlashVerseNumbers%": "Chapter/Verse Numbers", + "%checks_checkName_charactersParenthesesCombinations%": "Characters (Combinations)", + "%checks_checkName_checks%": "Checks", + "%checks_checkName_footnoteQuotes%": "Footnote Quotes", + "%checks_checkName_markers%": "Markers", + "%checks_checkName_numbers%": "Numbers", + "%checks_checkName_punctuationParenthesesSequences%": "Punctuation (Sequences)", + "%checks_checkName_quotations%": "Quotations", + "%checks_checkName_quotationTypes%": "Quotation types", + "%checks_checkName_references%": "References", + "%checks_checkName_repeatedWords%": "Repeated Words", + "%checks_checkName_unmatchedPairsOfPunctuation%": "Unmatched Pairs of Punctuation", + "%checks_defaultNoProject_noCurrentProject%": "No current project", + "%checks_title_runBasicChecks%": "Run Basic Checks", "%downloadUpdateProjectTab_aria_downloadableProjects%": "downloadable projects", "%downloadUpdateProjectTab_aria_downloadedProjects%": "downloaded projects", "%downloadUpdateProjectTab_listItem_delete%": "Delete", "%downloadUpdateProjectTab_subheader_downloadableProjects%": "Downloadable Projects", "%downloadUpdateProjectTab_subheader_downloadedProjects%": "Downloaded Projects", "%downloadUpdateProjectTab_title_downloadSlashUpdateProject%": "Download/Update Project", + "%general_button_submit%": "Submit", "%general_cancel%": "Cancel", + "%general_insertNote%": "Insert Note", "%general_loading%": "Loading", "%general_run%": "Run", - "%insertNote%": "Insert Note", - "%mainMenu_aboutPlatformBible%": "About Platform.Bible", - "%mainMenu_downloadSlashInstallResources%": "Download/Install Resources", - "%mainMenu_downloadSlashUpdateProject%": "Download/Update Project", - "%mainMenu_exit%": "Exit", - "%mainMenu_help%": "Help", - "%mainMenu_layout%": "Layout", - "%mainMenu_openProject%": "Open Project", - "%mainMenu_project%": "Project", - "%mainMenu_settings%": "Settings", - "%mainMenu_visitSupportBible%": "Visit Support.Bible", - "%mainMenu_window%": "Window", + "%mainMenu_menuItemName_aboutPlatformBible%": "About Platform.Bible", + "%mainMenu_menuItemName_downloadSlashInstallResources%": "Download/Install Resources", + "%mainMenu_menuItemName_exit%": "Exit", + "%mainMenu_menuItemName_help%": "Help", + "%mainMenu_menuItemName_layout%": "Layout", + "%mainMenu_menuItemName_openProject%": "Open Project", + "%mainMenu_menuItemName_project%": "Project", + "%mainMenu_menuItemName_settings%": "Settings", + "%mainMenu_menuItemName_visitSupportBible%": "Visit Support.Bible", + "%mainMenu_menuItemName_window%": "Window", + "%menuItemName_wordList%": "Word List", + "%product_name%": "Platform.Bible", + "%project_settings_platform_defaultFullName_nameMissing%": "*Name Missing*", + "%project_settings_platform_defaultLanguage_languageMissing%": "*Language Missing*", + "%project_settings_platform_defaultSettingName_noName%": "_NoName_", + "%project_settings_platform_group1_description%": "Project settings pertaining to the software overall", + "%project_settings_platform_settingName_fullName%": "Project Full Name", + "%project_settings_platform_settingName_group1%": "Platform Settings", + "%project_settings_platform_settingName_isEditable%": "Is Editable", + "%project_settings_platform_isEditable_description%": "Whether this project is editable. A project that is not editable is sometimes called a resource.", + "%project_settings_platform_settingName_language%": "Project Primary Language", + "%project_settings_platform_settingName_name%": "Project Short Name", + "%selectBooks_title_selectBooks%": "Select Books", + "%selectMultipleProjects_title_selectProjects%": "Select Projects", + "%selectProject_title_selectProject%": "Select Project", + "%settings_defaultMessage_loadingSetting%": "Loading setting", + "%settings_defaultSearchText_searchProjectSettingsEllipsis%": "Search Project Settings...", + "%settings_defaultSearchText_searchUserSettingsEllipsis%": "Search User Settings...", + "%settings_platform_group1_description%": "Settings pertaining to the software overall", + "%settings_platform_settingName_group1%": "Platform Settings", + "%settings_platform_settingName_interfaceLanguage%": "Interface Language", + "%settings_platform_settingName_paratextDataLastRegistryDataCachedTimes%": "ParatextData Last Registry Data Cached Times", + "%settings_platform_settingName_ptxUtilsMementoData%": "PtxUtils Memento Data", + "%settings_platform_settingName_verseRef%": "Current Verse Reference", + "%settings_title_projectSettings%": "Project Settings", + "%settings_title_userSettings%": "User Settings", "%some_localization_key%": "This is the English text for %some_localization_key%.", - "%submitButton%": "Submit", - "%tab_error%": "Error", - "%tab_unknown%": "Unknown", - "%tabAria_tab%": "Tab", - "%webView_edit%": "Edit", - "%webView_openProjectSettings%": "Open Project Settings", - "%webView_project%": "Project", - "%webView_projectAssignmentsAndProgress%": "Assignments and Progress", + "%tab_aria_tab%": "Tab", + "%tab_title_error%": "Error", + "%tab_title_unknown%": "Unknown", "%webView_defaultTitle_webView%": "Web View", - "%wordList%": "Word List", - "%selectBooks_selectBooks%": "Select Books", - "%selectProject_selectProject%": "Select Project", - "%selectMultipleProjects_selectProjects%": "Select Projects", - "%settings_loadingSetting%": "Loading setting", - "%settings_platform_group1_label%": "Platform Settings", - "%settings_searchProjectSettingsEllipsis%": "Search Project Settings...", - "%settings_searchUserSettingsEllipsis%": "Search User Settings...", - "%settings_platform_group1_description%": "Settings pertaining to the software overall", - "%settings_platform_verseRef_label%": "Current Verse Reference", - "%settings_platform_interfaceLanguage_label%": "Interface Language", - "%settings_platform_ptxUtilsMementoData_label%": "PtxUtils Memento Data", - "%settings_platform_paratextDataLastRegistryDataCachedTimes_label%": "ParatextData Last Registry Data Cached Times", - "%settings_projectSettings%": "Project Settings", - "%settings_userSettings%": "User Settings", - "%project_settings_platform_group1_label%": "Platform Settings", - "%project_settings_platform_group1_description%": "Project settings pertaining to the software overall", - "%project_settings_platform_name_label%": "Project Short Name", - "%project_name_missing%": "_NoName_", - "%project_settings_platform_fullName_label%": "Project Full Name", - "%project_full_name_missing%": "*Name Missing*", - "%project_language_missing%": "*Language Missing*", - "%project_settings_platform_language_label%": "Project Primary Language", - "%project_settings_platform_isEditable_label%": "Is Editable", - "%project_settings_platform_isEditable_description%": "Whether this project is editable. A project that is not editable is sometimes called a resource." + "%webView_menuItemName_edit%": "Edit", + "%webView_menuItemName_openProjectSettings%": "Open Project Settings", + "%webView_menuItemName_project%": "Project", + "%webView_menuItemName_projectAssignmentsAndProgress%": "Assignments and Progress", + "%webView_title_projectId_formatString%": "{projectId} {editable}" } diff --git a/assets/localization/fr.json b/assets/localization/fr.json index bd3147e528..4b7f3d5626 100644 --- a/assets/localization/fr.json +++ b/assets/localization/fr.json @@ -1,5 +1,5 @@ { "%some_localization_key%": "Ceci est le texte en français pour %some_localization_key%.", - "%submitButton%": "Soumettre", + "%general_button_submit%": "Soumettre", "%Book.Gen%": "Genèse" } diff --git a/extensions/src/hello-world/contributions/localizedStrings.json b/extensions/src/hello-world/contributions/localizedStrings.json index 20feb57137..d581d92a42 100644 --- a/extensions/src/hello-world/contributions/localizedStrings.json +++ b/extensions/src/hello-world/contributions/localizedStrings.json @@ -1,10 +1,10 @@ { "metadata": { "%helloWorld_webViewMenu_project%": { - "fallbackKey": "%mainMenu_project%" + "fallbackKey": "%mainMenu_menuItemName_project%" }, "%mainMenu_openHelloWorldProject%": { - "fallbackKey": "%mainMenu_openProject%" + "fallbackKey": "%mainMenu_menuItemName_openProject%" } }, "localizedStrings": { diff --git a/extensions/src/hello-world/contributions/menus.json b/extensions/src/hello-world/contributions/menus.json index a24114cef5..b4fad7b481 100644 --- a/extensions/src/hello-world/contributions/menus.json +++ b/extensions/src/hello-world/contributions/menus.json @@ -85,7 +85,7 @@ "command": "helloWorld.openViewerByWebViewId" }, { - "label": "%webView_openProjectSettings%", + "label": "%webView_menuItemName_openProjectSettings%", "group": "helloWorld.projectGroup", "order": 3, "command": "platform.openProjectSettings" diff --git a/extensions/src/hello-world/src/web-views/hello-world.web-view.tsx b/extensions/src/hello-world/src/web-views/hello-world.web-view.tsx index 7d11be13d8..005668ebf8 100644 --- a/extensions/src/hello-world/src/web-views/hello-world.web-view.tsx +++ b/extensions/src/hello-world/src/web-views/hello-world.web-view.tsx @@ -74,7 +74,7 @@ globalThis.webViewComponent = function HelloWorld({ const selectProjectsPrompt = '%selectProjects_prompt%'; const selectProjectsTitle = '%selectProjects_title%'; const selectProjectTitle = '%selectProject_title%'; - const submit = '%submitButton%'; + const submit = '%general_button_submit%'; const testException = '%helloWorld_throw_test_exception%'; const testMe = '%helloWorld_testMe%'; diff --git a/extensions/src/platform-scripture-editor/src/main.ts b/extensions/src/platform-scripture-editor/src/main.ts index a83ba3b76a..fc03871efb 100644 --- a/extensions/src/platform-scripture-editor/src/main.ts +++ b/extensions/src/platform-scripture-editor/src/main.ts @@ -6,13 +6,14 @@ import type { SavedWebViewDefinition, WebViewDefinition, } from '@papi/core'; -import { LanguageStrings } from 'platform-bible-utils'; +import { formatReplacementString, LanguageStrings } from 'platform-bible-utils'; import platformScriptureEditorWebView from './platform-scripture-editor.web-view?inline'; import platformScriptureEditorWebViewStyles from './platform-scripture-editor.web-view.scss?inline'; logger.info('Scripture Editor is importing!'); const scriptureEditorWebViewType = 'platformScriptureEditor.react'; +const projectIdTitleFormatStr = '%webView_title_projectId_formatString%'; const editable = '%webView_platformScriptureEditor_editable%'; const resourceViewer = '%webView_platformScriptureEditor_resourceViewer%'; const scriptureEditor = '%webView_platformScriptureEditor_scriptureEditor%'; @@ -24,7 +25,7 @@ interface PlatformScriptureEditorOptions extends GetWebViewOptions { async function getLocalizations(): Promise { const localizationData = await papi.localization.getLocalizedStrings({ - localizeKeys: [editable, resourceViewer, scriptureEditor], + localizeKeys: [editable, projectIdTitleFormatStr, resourceViewer, scriptureEditor], locales: ['en'], }); return localizationData; @@ -116,6 +117,7 @@ const scriptureEditorWebViewProvider: IWebViewProvider = { ); const localizedStrings = await getLocalizations(); + const localizedProjectIdTitleFormatStr = localizedStrings[projectIdTitleFormatStr]; const localizedEditable = localizedStrings[editable]; const localizedResourceViewer = localizedStrings[resourceViewer]; const localizedScriptureEditor = localizedStrings[scriptureEditor]; @@ -125,11 +127,13 @@ const scriptureEditorWebViewProvider: IWebViewProvider = { const isReadOnly = getWebViewOptions.isReadOnly || savedWebView.state?.isReadOnly; let title = ''; if (projectId) { - title = `${ - (await ( - await papi.projectDataProviders.get('platform.base', projectId) - ).getSetting('platform.name')) ?? projectId - }${isReadOnly ? '' : ` ${localizedEditable}`}`; + title = formatReplacementString(localizedProjectIdTitleFormatStr, { + projectId: + (await ( + await papi.projectDataProviders.get('platform.base', projectId) + ).getSetting('platform.name')) ?? projectId, + editable: isReadOnly ? '' : localizedEditable, + }); } else title = isReadOnly ? localizedResourceViewer : localizedScriptureEditor; return { diff --git a/lib/platform-bible-react/src/components/mui/contextMenu.component.onClick.test.tsx b/lib/platform-bible-react/src/components/mui/contextMenu.component.onClick.test.tsx index 4a4aab86e0..dbef9e5f79 100644 --- a/lib/platform-bible-react/src/components/mui/contextMenu.component.onClick.test.tsx +++ b/lib/platform-bible-react/src/components/mui/contextMenu.component.onClick.test.tsx @@ -34,7 +34,7 @@ describe('ContextMenu', () => { const contextMenuTarget = screen.getByText('click me'); fireEvent.contextMenu(contextMenuTarget); - const insertNoteItem = screen.getByRole('menuitem', { name: '%insertNote%' }); + const insertNoteItem = screen.getByRole('menuitem', { name: '%general_insertNote%' }); fireEvent.click(insertNoteItem); diff --git a/lib/platform-bible-react/src/components/mui/contextMenu.component.open.render.test.tsx b/lib/platform-bible-react/src/components/mui/contextMenu.component.open.render.test.tsx index 5b2363753b..494a41fd1a 100644 --- a/lib/platform-bible-react/src/components/mui/contextMenu.component.open.render.test.tsx +++ b/lib/platform-bible-react/src/components/mui/contextMenu.component.open.render.test.tsx @@ -67,7 +67,7 @@ describe('ContextMenu renders', () => { it('the last group in a column without a final separator', () => { const htmlForWordListItem = allMenuItems .map((i) => i.outerHTML) - .find((html) => html && /%wordList%/.test(html)); + .find((html) => html && /%menuItemName_wordList%/.test(html)); expect(htmlForWordListItem).toBeDefined(); expect(htmlForWordListItem).not.toMatch('hasDivider'); diff --git a/lib/platform-bible-react/src/components/mui/gridMenu.component.render.test.tsx b/lib/platform-bible-react/src/components/mui/gridMenu.component.render.test.tsx index 6cdb6e731f..fa7c08119b 100644 --- a/lib/platform-bible-react/src/components/mui/gridMenu.component.render.test.tsx +++ b/lib/platform-bible-react/src/components/mui/gridMenu.component.render.test.tsx @@ -47,9 +47,9 @@ describe('GridMenu renders', () => { html: screen.getByRole('menu', { name: 'paratext.paratext' }), label: '%mainMenu_Paratext%', }, - { html: screen.getByRole('menu', { name: 'platform.window' }), label: '%mainMenu_Window%' }, - { html: screen.getByRole('menu', { name: 'platform.layout' }), label: '%mainMenu_Layout%' }, - { html: screen.getByRole('menu', { name: 'platform.help' }), label: '%mainMenu_Help%' }, + { html: screen.getByRole('menu', { name: 'platform.window' }), label: '%mainMenu_menuItemName_window%' }, + { html: screen.getByRole('menu', { name: 'platform.layout' }), label: '%mainMenu_menuItemName_layout%' }, + { html: screen.getByRole('menu', { name: 'platform.help' }), label: '%mainMenu_menuItemName_help%' }, ]; expectedColumns.forEach((column) => { diff --git a/lib/platform-bible-react/src/components/mui/sample.composed.full.menu.json b/lib/platform-bible-react/src/components/mui/sample.composed.full.menu.json index daab549fb1..34aa9a49e2 100644 --- a/lib/platform-bible-react/src/components/mui/sample.composed.full.menu.json +++ b/lib/platform-bible-react/src/components/mui/sample.composed.full.menu.json @@ -2,9 +2,9 @@ "mainMenu": { "columns": { "paratext.paratext": { "label": "%mainMenu_Paratext%", "order": 0 }, - "platform.window": { "label": "%mainMenu_Window%", "order": 1 }, - "platform.layout": { "label": "%mainMenu_Layout%", "order": 2 }, - "platform.help": { "label": "%mainMenu_Help%", "order": 3, "isExtensible": true }, + "platform.window": { "label": "%mainMenu_menuItemName_window%", "order": 1 }, + "platform.layout": { "label": "%mainMenu_menuItemName_layout%", "order": 2 }, + "platform.help": { "label": "%mainMenu_menuItemName_help%", "order": 3, "isExtensible": true }, "isExtensible": true }, "groups": { @@ -92,8 +92,8 @@ }, "defaultWebViewTopMenu": { "columns": { - "platform.project": { "label": "%webView_Project%", "order": 1 }, - "platform.edit": { "label": "%webView_Edit%", "order": 2, "isExtensible": true } + "platform.project": { "label": "%webView_menuItemName_project%", "order": 1 }, + "platform.edit": { "label": "%webView_menuItemName_edit%", "order": 2, "isExtensible": true } }, "groups": { "platform.projectTop": { "column": "platform.project", "order": 1 }, @@ -127,14 +127,14 @@ }, "items": [ { - "label": "%insertNote%", + "label": "%general_insertNote%", "localizeNotes": "Web view context menu > Insert note...", "group": "platform.insert", "order": 1, "command": "platform.insertNote" }, { - "label": "%wordList%", + "label": "%menuItemName_wordList%", "localizeNotes": "Web view context menu > Word list...", "group": "platform.wordList", "order": 1, diff --git a/src/extension-host/data/core-project-settings-info.data.ts b/src/extension-host/data/core-project-settings-info.data.ts index f468a70e38..caa81390a6 100644 --- a/src/extension-host/data/core-project-settings-info.data.ts +++ b/src/extension-host/data/core-project-settings-info.data.ts @@ -6,23 +6,23 @@ import { ProjectSettingsContribution } from 'platform-bible-utils'; /** Info about all project settings built into core. Does not contain info for extensions' settings */ export const platformProjectSettings: ProjectSettingsContribution = { - label: '%project_settings_platform_group1_label%', + label: '%project_settings_platform_settingName_group1%', description: '%project_settings_platform_group1_description%', properties: { 'platform.name': { - label: '%project_settings_platform_name_label%', - default: '%project_name_missing%', + label: '%project_settings_platform_settingName_name%', + default: '%project_settings_platform_defaultSettingName_noName%', }, 'platform.fullName': { - label: '%project_settings_platform_fullName_label%', - default: '%project_full_name_missing%', + label: '%project_settings_platform_settingName_fullName%', + default: '%project_settings_platform_defaultFullName_nameMissing%', }, 'platform.language': { - label: '%project_settings_platform_language_label%', - default: '%project_language_missing%', + label: '%project_settings_platform_settingName_language%', + default: '%project_settings_platform_defaultLanguage_languageMissing%', }, 'platform.isEditable': { - label: '%project_settings_platform_isEditable_label%', + label: '%project_settings_platform_settingName_isEditable%', description: '%project_settings_platform_isEditable_description%', default: true, }, diff --git a/src/extension-host/data/core-settings-info.data.ts b/src/extension-host/data/core-settings-info.data.ts index afdb5e8842..b8b67f17ab 100644 --- a/src/extension-host/data/core-settings-info.data.ts +++ b/src/extension-host/data/core-settings-info.data.ts @@ -3,23 +3,23 @@ import { isString, ScriptureReference, SettingsContribution } from 'platform-bib /** Contribution of all settings built into core. Does not contain info for extensions' settings */ export const platformSettings: SettingsContribution = { - label: '%settings_platform_group1_label%', + label: '%settings_platform_settingName_group1%', description: '%settings_platform_group1_description%', properties: { 'platform.verseRef': { - label: '%settings_platform_verseRef_label%', + label: '%settings_platform_settingName_verseRef%', default: { bookNum: 1, chapterNum: 1, verseNum: 1 }, }, 'platform.interfaceLanguage': { - label: '%settings_platform_interfaceLanguage_label%', + label: '%settings_platform_settingName_interfaceLanguage%', default: ['eng'], }, 'platform.ptxUtilsMementoData': { - label: '%settings_platform_ptxUtilsMementoData_label%', + label: '%settings_platform_settingName_ptxUtilsMementoData%', default: {}, }, 'platform.paratextDataLastRegistryDataCachedTimes': { - label: '%settings_platform_paratextDataLastRegistryDataCachedTimes_label%', + label: '%settings_platform_settingName_paratextDataLastRegistryDataCachedTimes%', default: {}, }, }, diff --git a/src/extension-host/data/menu.data.json b/src/extension-host/data/menu.data.json index 41651dae00..ca2b19e331 100644 --- a/src/extension-host/data/menu.data.json +++ b/src/extension-host/data/menu.data.json @@ -1,10 +1,10 @@ { "mainMenu": { "columns": { - "platform.project": { "label": "%mainMenu_project%", "order": 1 }, - "platform.window": { "label": "%mainMenu_window%", "order": 2 }, - "platform.layout": { "label": "%mainMenu_layout%", "order": 3 }, - "platform.help": { "label": "%mainMenu_help%", "order": 4 }, + "platform.project": { "label": "%mainMenu_menuItemName_project%", "order": 1 }, + "platform.window": { "label": "%mainMenu_menuItemName_window%", "order": 2 }, + "platform.layout": { "label": "%mainMenu_menuItemName_layout%", "order": 3 }, + "platform.help": { "label": "%mainMenu_menuItemName_help%", "order": 4 }, "isExtensible": true }, "groups": { @@ -26,7 +26,7 @@ }, "items": [ { - "label": "%mainMenu_openProject%", + "label": "%mainMenu_menuItemName_openProject%", "localizeNotes": "Application main menu > Project > Open Project", "group": "platform.projectProjects", "order": 1, @@ -40,35 +40,35 @@ "command": "platform.openDownloadUpdateProjectDialog" }, { - "label": "%mainMenu_downloadSlashInstallResources%", + "label": "%mainMenu_menuItemName_downloadSlashInstallResources%", "localizeNotes": "Application main menu > Project > Download/Install Resources", "group": "platform.projectResources", "order": 1, "command": "platform.downloadAndInstallResources" }, { - "label": "%mainMenu_settings%", + "label": "%mainMenu_menuItemName_settings%", "localizeNotes": "Application main menu > Project > Settings", "group": "platform.projectSettings", "order": 1, "command": "platform.openUserSettings" }, { - "label": "%mainMenu_exit%", + "label": "%mainMenu_menuItemName_exit%", "localizeNotes": "Application main menu > Project > Exit", "group": "platform.projectMisc", "order": 999999999, "command": "platform.quit" }, { - "label": "%mainMenu_visitSupportBible%", + "label": "%mainMenu_menuItemName_visitSupportBible%", "localizeNotes": "Application main menu > Help > Visit Support.Bible", "group": "platform.helpMisc", "order": 1, "command": "platform.visitSupportPage" }, { - "label": "%mainMenu_aboutPlatformBible%", + "label": "%mainMenu_menuItemName_aboutPlatformBible%", "localizeNotes": "Application main menu > Help > About Platform.Bible", "group": "platform.helpMisc", "order": 2, @@ -78,8 +78,8 @@ }, "defaultWebViewTopMenu": { "columns": { - "platform.project": { "label": "%webView_project%", "order": 1 }, - "platform.edit": { "label": "%webView_edit%", "order": 2, "isExtensible": true } + "platform.project": { "label": "%webView_menuItemName_project%", "order": 1 }, + "platform.edit": { "label": "%webView_menuItemName_edit%", "order": 2, "isExtensible": true } }, "groups": { "platform.projectTop": { "column": "platform.project", "order": 1, "isExtensible": true }, @@ -91,14 +91,14 @@ }, "items": [ { - "label": "%webView_projectAssignmentsAndProgress%", + "label": "%webView_menuItemName_projectAssignmentsAndProgress%", "localizeNotes": "Web view main menu > Project > Assignments and progress...", "group": "platform.projectTop", "order": 2, "command": "platform.assignments" }, { - "label": "%webView_openProjectSettings%", + "label": "%webView_menuItemName_openProjectSettings%", "localizeNotes": "Web view main menu > Project > Open Project Settings...", "group": "platform.projectTop", "order": 3, @@ -113,14 +113,14 @@ }, "items": [ { - "label": "%insertNote%", + "label": "%general_insertNote%", "localizeNotes": "Web view context menu > Insert note...", "group": "platform.insert", "order": 1, "command": "platform.insertNote" }, { - "label": "%wordList%", + "label": "%menuItemName_wordList%", "localizeNotes": "Web view context menu > Word list...", "group": "platform.wordList", "order": 1, diff --git a/src/extension-host/services/localization.service-host.test.ts b/src/extension-host/services/localization.service-host.test.ts index 7f1686d504..abc0522fa0 100644 --- a/src/extension-host/services/localization.service-host.test.ts +++ b/src/extension-host/services/localization.service-host.test.ts @@ -6,11 +6,11 @@ import { LocalizeKey } from 'platform-bible-utils'; const MOCK_FILES: { [uri: string]: string } = { 'resources://assets/localization/en.json': `{ "%some_localization_key%": "This is the English text for %some_localization_key%.", - "%submitButton%": "Submit" + "%general_button_submit%": "Submit" }`, 'resources://assets/localization/fr.json': `{ "%some_localization_key%": "Ceci est le texte en français pour %some_localization_key%.", - "%submitButton%": "Soumettre" + "%general_button_submit%": "Soumettre" }`, 'resources://assets/localization/metadata.json': `{ "%yes%": { @@ -71,7 +71,7 @@ afterEach(() => { }); test('Correct localized value returned to match single localizeKey', async () => { - const LOCALIZE_KEY = '%submitButton%'; + const LOCALIZE_KEY = '%general_button_submit%'; const response = await localizationDataProviderEngine.getLocalizedString({ localizeKey: LOCALIZE_KEY, locales: ['fr'], @@ -80,13 +80,13 @@ test('Correct localized value returned to match single localizeKey', async () => }); test('Correct localized values returned to match array of localizeKeys', async () => { - const LOCALIZE_KEYS: LocalizeKey[] = ['%submitButton%', '%some_localization_key%']; + const LOCALIZE_KEYS: LocalizeKey[] = ['%general_button_submit%', '%some_localization_key%']; const response = await localizationDataProviderEngine.getLocalizedStrings({ localizeKeys: LOCALIZE_KEYS, locales: ['fr'], }); expect(response).toEqual({ - '%submitButton%': 'Soumettre', + '%general_button_submit%': 'Soumettre', '%some_localization_key%': 'Ceci est le texte en français pour %some_localization_key%.', }); }); @@ -124,14 +124,14 @@ test('Keys returned with localizeKeys that do not exist', async () => { }); test('Strings and keys returned with localizeKeys where one exists but the other does not', async () => { - const LOCALIZE_KEYS: LocalizeKey[] = ['%submitButton%', '%the_wrong_key%']; + const LOCALIZE_KEYS: LocalizeKey[] = ['%general_button_submit%', '%the_wrong_key%']; expect( await localizationDataProviderEngine.getLocalizedStrings({ localizeKeys: LOCALIZE_KEYS, locales: ['fr'], }), ).toEqual({ - '%submitButton%': 'Soumettre', + '%general_button_submit%': 'Soumettre', '%the_wrong_key%': '%the_wrong_key%', }); expect(logger.warn).toHaveBeenCalledWith( @@ -140,7 +140,7 @@ test('Strings and keys returned with localizeKeys where one exists but the other }); test('Error returned with localizeKey and incorrectly formatted language code', async () => { - const LOCALIZE_KEY = '%submitButton%'; // irrelevant because it will throw for language code before it accesses key/value pairs + const LOCALIZE_KEY = '%general_button_submit%'; // irrelevant because it will throw for language code before it accesses key/value pairs await expect( localizationDataProviderEngine.getLocalizedString({ localizeKey: LOCALIZE_KEY, @@ -153,7 +153,7 @@ test('Error returned with localizeKey and incorrectly formatted language code', }); test('Error returned with localizeKeys and incorrect language code', async () => { - const LOCALIZE_KEYS: LocalizeKey[] = ['%submitButton%', '%some_localization_key%']; // irrelevant because it will throw for language code before it accesses key/value pairs + const LOCALIZE_KEYS: LocalizeKey[] = ['%general_button_submit%', '%some_localization_key%']; // irrelevant because it will throw for language code before it accesses key/value pairs await expect( localizationDataProviderEngine.getLocalizedStrings({ localizeKeys: LOCALIZE_KEYS, @@ -166,7 +166,7 @@ test('Error returned with localizeKeys and incorrect language code', async () => }); test('Default language is english when no language provided with localizeKey', async () => { - const LOCALIZE_KEY = '%submitButton%'; + const LOCALIZE_KEY = '%general_button_submit%'; const response = await localizationDataProviderEngine.getLocalizedString({ localizeKey: LOCALIZE_KEY, }); @@ -174,18 +174,18 @@ test('Default language is english when no language provided with localizeKey', a }); test('Default language is english when no language provided with localizeKeys', async () => { - const LOCALIZE_KEYS: LocalizeKey[] = ['%submitButton%', '%some_localization_key%']; + const LOCALIZE_KEYS: LocalizeKey[] = ['%general_button_submit%', '%some_localization_key%']; const response = await localizationDataProviderEngine.getLocalizedStrings({ localizeKeys: LOCALIZE_KEYS, }); expect(response).toEqual({ '%some_localization_key%': 'This is the English text for %some_localization_key%.', - '%submitButton%': 'Submit', + '%general_button_submit%': 'Submit', }); }); test('Good key and missing but valid language code return default English', async () => { - const LOCALIZE_KEY = '%submitButton%'; + const LOCALIZE_KEY = '%general_button_submit%'; globalThis.isPackaged = true; const response = await localizationDataProviderEngine.getLocalizedString({ localizeKey: LOCALIZE_KEY, @@ -195,13 +195,13 @@ test('Good key and missing but valid language code return default English', asyn }); test('Good keys and missing but valid language code return default English', async () => { - const LOCALIZE_KEYS: LocalizeKey[] = ['%submitButton%', '%some_localization_key%']; + const LOCALIZE_KEYS: LocalizeKey[] = ['%general_button_submit%', '%some_localization_key%']; const response = await localizationDataProviderEngine.getLocalizedStrings({ localizeKeys: LOCALIZE_KEYS, locales: ['qya-Latn'], }); expect(response).toEqual({ '%some_localization_key%': 'This is the English text for %some_localization_key%.', - '%submitButton%': 'Submit', + '%general_button_submit%': 'Submit', }); }); diff --git a/src/extension-host/services/menu-data.service-host.test.tsx b/src/extension-host/services/menu-data.service-host.test.tsx index 8cd8e69c06..26e37f823a 100644 --- a/src/extension-host/services/menu-data.service-host.test.tsx +++ b/src/extension-host/services/menu-data.service-host.test.tsx @@ -6,9 +6,9 @@ const MOCK_MENU_DATA: PlatformMenus = { mainMenu: { columns: { 'paratext.paratext': { label: '%mainMenu_Paratext%', order: 0 }, - 'platform.window': { label: '%mainMenu_Window%', order: 1 }, - 'platform.layout': { label: '%mainMenu_Layout%', order: 2 }, - 'platform.help': { label: '%mainMenu_Help%', order: 3, isExtensible: true }, + 'platform.window': { label: '%mainMenu_menuItemName_window%', order: 1 }, + 'platform.layout': { label: '%mainMenu_menuItemName_layout%', order: 2 }, + 'platform.help': { label: '%mainMenu_menuItemName_help%', order: 3, isExtensible: true }, isExtensible: true, }, groups: { @@ -95,8 +95,8 @@ const MOCK_MENU_DATA: PlatformMenus = { }, defaultWebViewTopMenu: { columns: { - 'platform.project': { label: '%webView_Project%', order: 1 }, - 'platform.edit': { label: '%webView_Edit%', order: 2, isExtensible: true }, + 'platform.project': { label: '%webView_menuItemName_project%', order: 1 }, + 'platform.edit': { label: '%webView_menuItemName_edit%', order: 2, isExtensible: true }, }, groups: { 'platform.projectTop': { column: 'platform.project', order: 1 }, @@ -130,14 +130,14 @@ const MOCK_MENU_DATA: PlatformMenus = { }, items: [ { - label: '%insertNote%', + label: '%general_insertNote%', localizeNotes: 'Web view context menu > Insert note...', group: 'platform.insert', order: 1, command: 'platform.insertNote', }, { - label: '%wordList%', + label: '%menuItemName_wordList%', localizeNotes: 'Web view context menu > Word list...', group: 'platform.wordList', order: 1, diff --git a/src/extension-host/services/project-settings.service-host.test.ts b/src/extension-host/services/project-settings.service-host.test.ts index c86ee5a9e4..cef075c455 100644 --- a/src/extension-host/services/project-settings.service-host.test.ts +++ b/src/extension-host/services/project-settings.service-host.test.ts @@ -13,15 +13,15 @@ jest.mock('@extension-host/data/core-project-settings-info.data', () => ({ ...jest.requireActual('@extension-host/data/core-project-settings-info.data'), __esModule: true, platformProjectSettings: { - label: '%project_settings_platform_group1_label%', + label: '%project_settings_platform_settingName_group1%', description: '%project_settings_platform_group1_description%', properties: { 'platform.fullName': { - label: '%project_settings_platform_fullName_label%', + label: '%project_settings_platform_settingName_fullName%', default: '%test_project_full_name_missing%', }, 'platform.language': { - label: '%project_settings_platform_language_label%', + label: '%project_settings_platform_settingName_language%', default: '%test_project_language_missing%', }, }, diff --git a/src/extension-host/services/settings.service-host.test.ts b/src/extension-host/services/settings.service-host.test.ts index f2d1e50c8a..5789020c19 100644 --- a/src/extension-host/services/settings.service-host.test.ts +++ b/src/extension-host/services/settings.service-host.test.ts @@ -40,11 +40,11 @@ jest.mock('@extension-host/data/core-settings-info.data', () => ({ default: '%missing%', }, 'platform.verseRef': { - label: '%settings_platform_verseRef_label%', + label: '%settings_platform_settingName_verseRef%', default: { bookNum: 1, chapterNum: 1, verseNum: 1 }, }, 'platform.interfaceLanguage': { - label: '%settings_platform_interfaceLanguage_label%', + label: '%settings_platform_settingName_interfaceLanguage%', default: ['eng'], }, }, diff --git a/src/renderer/components/dialogs/select-books-dialog.component.tsx b/src/renderer/components/dialogs/select-books-dialog.component.tsx index 85aa5c38e3..bc0f275674 100644 --- a/src/renderer/components/dialogs/select-books-dialog.component.tsx +++ b/src/renderer/components/dialogs/select-books-dialog.component.tsx @@ -49,7 +49,7 @@ function SelectBooksDialog({ ); } -const localizeSelectBooksKey: LocalizeKey = `%selectBooks_selectBooks%`; +const localizeSelectBooksKey: LocalizeKey = `%selectBooks_title_selectBooks%`; const SELECT_BOOKS_DIALOG: DialogDefinition = Object.freeze({ ...DIALOG_BASE, diff --git a/src/renderer/components/dialogs/select-multiple-projects.dialog.tsx b/src/renderer/components/dialogs/select-multiple-projects.dialog.tsx index 7fb4f4a66d..f9abd3835e 100644 --- a/src/renderer/components/dialogs/select-multiple-projects.dialog.tsx +++ b/src/renderer/components/dialogs/select-multiple-projects.dialog.tsx @@ -103,7 +103,7 @@ function SelectMultipleProjectsDialog({ ); } -const localizeSelectProjectsKey: LocalizeKey = '%selectMultipleProjects_selectProjects%'; +const localizeSelectProjectsKey: LocalizeKey = '%selectMultipleProjects_title_selectProjects%'; const SELECT_MULTIPLE_PROJECTS_DIALOG: DialogDefinition< typeof SELECT_MULTIPLE_PROJECTS_DIALOG_TYPE diff --git a/src/renderer/components/dialogs/select-project.dialog.tsx b/src/renderer/components/dialogs/select-project.dialog.tsx index 6c09e6e60e..8130e3b784 100644 --- a/src/renderer/components/dialogs/select-project.dialog.tsx +++ b/src/renderer/components/dialogs/select-project.dialog.tsx @@ -79,7 +79,7 @@ function SelectProjectDialog({ ); } -const localizeSelectProject: LocalizeKey = '%selectProject_selectProject%'; +const localizeSelectProject: LocalizeKey = '%selectProject_title_selectProject%'; const SELECT_PROJECT_DIALOG: DialogDefinition = Object.freeze({ ...DIALOG_BASE, diff --git a/src/renderer/components/docking/error-tab.component.tsx b/src/renderer/components/docking/error-tab.component.tsx index b92330182f..3b62001179 100644 --- a/src/renderer/components/docking/error-tab.component.tsx +++ b/src/renderer/components/docking/error-tab.component.tsx @@ -16,7 +16,7 @@ export default function ErrorTab({ errorMessage }: { errorMessage: string }) { ); } -const localizeError: LocalizeKey = '%tab_error%'; +const localizeError: LocalizeKey = '%tab_title_error%'; /** Creates a new error message tab with the specified error message */ export const createErrorTab = (errorMessage: string): TabInfo => { diff --git a/src/renderer/components/docking/platform-tab-title.component.tsx b/src/renderer/components/docking/platform-tab-title.component.tsx index 3934c6c58e..40a0af93fc 100644 --- a/src/renderer/components/docking/platform-tab-title.component.tsx +++ b/src/renderer/components/docking/platform-tab-title.component.tsx @@ -36,7 +36,7 @@ export default function PlatformTabTitle({ }: PlatformTabTitleProps) { const menuSelector = webViewType ?? 'invalid.invalid'; - const tabAria: LocalizeKey = '%tabAria_tab%'; + const tabAria: LocalizeKey = '%tab_aria_tab%'; const [localizedStrings] = useLocalizedStrings(isLocalizeKey(text) ? [text, tabAria] : [tabAria]); const title = isLocalizeKey(text) ? localizedStrings[text] : text; const tabLabel = localizedStrings[tabAria]; diff --git a/src/renderer/components/run-basic-checks-dialog/book-selector.component.tsx b/src/renderer/components/run-basic-checks-dialog/book-selector.component.tsx index eac17b6245..0b718a8798 100644 --- a/src/renderer/components/run-basic-checks-dialog/book-selector.component.tsx +++ b/src/renderer/components/run-basic-checks-dialog/book-selector.component.tsx @@ -30,11 +30,11 @@ export default function BookSelector({ BookSelectionMode.CURRENT_BOOK, ); - const selectBooksPromptKey = '%bookSelector_selectOneOrMoreBooksToRunBasicChecksOn%'; - const selectBooksKey = '%bookSelector_selectBooks%'; - const currentBooksKey = '%bookSelector_currentBook%'; - const chooseBooksKey = '%bookSelector_chooseBooks%'; - const chooseKey = '%bookSelector_chooseEllipsis%'; + const selectBooksPromptKey = '%bookSelector_dialogPrompt_selectOneOrMoreBooksToRunBasicChecksOn%'; + const selectBooksKey = '%bookSelector_title_selectBooks%'; + const currentBooksKey = '%bookSelector_selectionMode_currentBook%'; + const chooseBooksKey = '%bookSelector_selectionMode_chooseBooks%'; + const chooseKey = '%bookSelector_submitButton_chooseEllipsis%'; const [localizedStrings] = useLocalizedStrings([ selectBooksPromptKey, selectBooksKey, diff --git a/src/renderer/components/run-basic-checks-dialog/run-basic-checks-tab.component.tsx b/src/renderer/components/run-basic-checks-dialog/run-basic-checks-tab.component.tsx index b2882c6cde..a3ec0376b8 100644 --- a/src/renderer/components/run-basic-checks-dialog/run-basic-checks-tab.component.tsx +++ b/src/renderer/components/run-basic-checks-dialog/run-basic-checks-tab.component.tsx @@ -34,18 +34,18 @@ type BasicCheck = { }; export function fetchChecks(): BasicCheck[] { - const chapterVerseNumbersKey = '%checks_chapterSlashVerseNumbers%'; - const markersKey = '%checks_markers%'; - const charactersCombinationsKey = '%checks_charactersParenthesesCombinations%'; - const punctuationSequencesKey = '%checks_punctuationParenthesesSequences%'; - const referencesKey = '%checks_references%'; - const footnoteQuotesKey = '%checks_footnoteQuotes%'; - const capitalizationKey = '%checks_Capitalization%'; - const repeatedWordsKey = '%checks_repeatedWords%'; - const unmatchedPairsOfPunctuationKey = '%checks_unmatchedPairsOfPunctuation%'; - const quotationsKey = '%checks_quotations%'; - const quotationTypes = '%checks_quotationTypes%'; - const numbersKey = '%checks_numbers%'; + const chapterVerseNumbersKey = '%checks_checkName_chapterSlashVerseNumbers%'; + const markersKey = '%checks_checkName_markers%'; + const charactersCombinationsKey = '%checks_checkName_charactersParenthesesCombinations%'; + const punctuationSequencesKey = '%checks_checkName_punctuationParenthesesSequences%'; + const referencesKey = '%checks_checkName_references%'; + const footnoteQuotesKey = '%checks_checkName_footnoteQuotes%'; + const capitalizationKey = '%checks_checkName_capitalization%'; + const repeatedWordsKey = '%checks_checkName_repeatedWords%'; + const unmatchedPairsOfPunctuationKey = '%checks_checkName_unmatchedPairsOfPunctuation%'; + const quotationsKey = '%checks_checkName_quotations%'; + const quotationTypes = '%checks_checkName_quotationTypes%'; + const numbersKey = '%checks_checkName_numbers%'; return [ { name: chapterVerseNumbersKey, @@ -104,17 +104,14 @@ export function fetchChecks(): BasicCheck[] { ]; } -function getLocalizedChecks(basicChecks: BasicCheck[]): BasicCheck[] { - basicChecks.forEach((c) => { - const [localizedStrings] = useLocalizedStrings(isLocalizeKey(c.name) ? [c.name] : []); - c.name = isLocalizeKey(c.name) ? localizedStrings[c.name] : c.name; - }); - return basicChecks; -} - export default function RunBasicChecksTab({ currentProjectId }: RunBasicChecksTabProps) { const basicChecks = fetchChecks(); - const localizedBasicChecks = getLocalizedChecks(basicChecks); + const localizationKeys: LocalizeKey[] = []; + basicChecks.forEach((c) => { + if (isLocalizeKey(c.name)) { + localizationKeys.push(c.name); + } + }); const [scrRef] = useSetting('platform.verseRef', defaultScrRef); const [selectedChecks, setSelectedChecks] = useState([]); @@ -124,18 +121,22 @@ export default function RunBasicChecksTab({ currentProjectId }: RunBasicChecksTa const [endChapter, setEndChapter] = useState(chapterCount); const currentBookId = useMemo(() => Canon.bookNumberToId(scrRef.bookNum), [scrRef]); - const noCurrentProjectKey = '%checks_noCurrentProject%'; + const noCurrentProjectKey = '%checks_defaultNoProject_noCurrentProject%'; const loadingKey = '%general_loading%'; - const checksKey = '%checks_checks%'; + const checksKey = '%checks_checkName_checks%'; const runKey = '%general_run%'; const cancelKey = '%general_cancel%'; const [localizedStrings] = useLocalizedStrings([ + ...localizationKeys, noCurrentProjectKey, loadingKey, checksKey, runKey, cancelKey, ]); + const localizedBasicChecks = basicChecks.map((c) => ({ + name: isLocalizeKey(c.name) ? localizedStrings[c.name] : c.name, + })); const localizedNoCurrentProject = localizedStrings[noCurrentProjectKey]; const localizedLoading = localizedStrings[loadingKey]; const localizedChecks = localizedStrings[checksKey]; @@ -254,7 +255,7 @@ export default function RunBasicChecksTab({ currentProjectId }: RunBasicChecksTa export const loadRunBasicChecksTab = (savedTabInfo: SavedTabInfo): TabInfo => { return { ...savedTabInfo, - tabTitle: '%checks_runBasicChecks%', + tabTitle: '%checks_title_runBasicChecks%', content: ( { return { ...savedTabInfo, - tabTitle: '%settings_projectSettings%', + tabTitle: '%settings_title_projectSettings%', content: , }; }; @@ -128,7 +128,7 @@ export const loadProjectSettingsTab = (savedTabInfo: SavedTabInfo): TabInfo => { export const loadUserSettingsTab = (savedTabInfo: SavedTabInfo): TabInfo => { return { ...savedTabInfo, - tabTitle: '%settings_userSettings%', + tabTitle: '%settings_title_userSettings%', content: , }; }; diff --git a/src/renderer/components/web-view.component.tsx b/src/renderer/components/web-view.component.tsx index 927a65888a..bca7b8b47a 100644 --- a/src/renderer/components/web-view.component.tsx +++ b/src/renderer/components/web-view.component.tsx @@ -16,7 +16,7 @@ import { IFRAME_SANDBOX_ALLOW_POPUPS, } from '@renderer/services/web-view.service-host'; import logger from '@shared/services/logger.service'; -import { isLocalizeKey, serialize } from 'platform-bible-utils'; +import { formatReplacementString, isLocalizeKey, serialize } from 'platform-bible-utils'; import { useLocalizedStrings } from '@renderer/hooks/papi-hooks'; export const TAB_TYPE_WEBVIEW = 'webView'; @@ -35,10 +35,19 @@ export default function WebView({ const iframeRef = useRef(undefined!); const webViewKey = '%webView_defaultTitle_webView%'; + const webViewTitleTypeFormatStr = '%webView_title_type_formatString%'; const [localizedStrings] = useLocalizedStrings( - title && isLocalizeKey(title) ? [title] : [webViewKey], + title && isLocalizeKey(title) + ? [title, webViewTitleTypeFormatStr] + : [webViewKey, webViewTitleTypeFormatStr], ); - const defaultTitle = title || `${webViewType || contentType} ${localizedStrings[webViewKey]}`; + const localizedWebViewTitleFormatStr = localizedStrings[webViewTitleTypeFormatStr]; + const defaultTitle = + title ?? + formatReplacementString(localizedWebViewTitleFormatStr, { + type: webViewType || contentType, + defaultTitle: localizedStrings[webViewKey], + }); const localizedTitle = title && isLocalizeKey(title) ? localizedStrings[title] : defaultTitle; /** Whether this webview's iframe will be populated by `src` as opposed to `srcdoc` */ @@ -102,7 +111,7 @@ export function updateWebViewTab(savedTabInfo: SavedTabInfo, data: WebViewDefini ...savedTabInfo, data, tabIconUrl: data.iconUrl, - tabTitle: data.title ?? '%tab_unknown%', + tabTitle: data.title ?? '%tab_title_unknown%', tabTooltip: data.tooltip ?? '', content: , }; @@ -140,7 +149,7 @@ export function loadWebViewTab(savedTabInfo: SavedTabInfo): TabInfo { data = { id: savedTabInfo.id, webViewType: 'Unknown', - title: '%tab_unknown%', + title: '%tab_title_unknown%', content: '', contentType: WebViewContentType.HTML, }; diff --git a/src/shared/models/docking-framework.model.ts b/src/shared/models/docking-framework.model.ts index 1f835c0e99..ce7ec85204 100644 --- a/src/shared/models/docking-framework.model.ts +++ b/src/shared/models/docking-framework.model.ts @@ -38,7 +38,10 @@ export type TabInfo = SavedTabInfo & { * Defaults to Platform.Bible logo */ tabIconUrl?: string; - /** Text to show on the title bar of the tab */ + /** + * Text to show (or a localizeKey that will automatically be localized) on the title bar of the + * tab + */ tabTitle: string | LocalizeKey; /** Text to show when hovering over the title bar of the tab */ tabTooltip?: string; diff --git a/src/shared/models/web-view.model.ts b/src/shared/models/web-view.model.ts index 7e91b07187..32b556c6d2 100644 --- a/src/shared/models/web-view.model.ts +++ b/src/shared/models/web-view.model.ts @@ -37,7 +37,10 @@ type WebViewDefinitionBase = { * Defaults to Platform.Bible logo */ iconUrl?: string; - /** Name of the tab for the WebView */ + /** + * Name of the tab (or a localizeKey for the name that will automatically be localized) for the + * WebView + */ title?: string | LocalizeKey; /** Tooltip that is shown when hovering over the webview title */ tooltip?: string; diff --git a/src/shared/utils/menu-document-combiner.test.ts b/src/shared/utils/menu-document-combiner.test.ts index 163a559824..2ef26250a7 100644 --- a/src/shared/utils/menu-document-combiner.test.ts +++ b/src/shared/utils/menu-document-combiner.test.ts @@ -4,9 +4,9 @@ import MenuDocumentCombiner from './menu-document-combiner'; const startingDoc = { mainMenu: { columns: { - 'platform.window': { label: '%mainMenu_Window%', order: 1 }, - 'platform.layout': { label: '%mainMenu_Layout%', order: 2 }, - 'platform.help': { label: '%mainMenu_Help%', order: 3, isExtensible: true }, + 'platform.window': { label: '%mainMenu_menuItemName_window%', order: 1 }, + 'platform.layout': { label: '%mainMenu_menuItemName_layout%', order: 2 }, + 'platform.help': { label: '%mainMenu_menuItemName_help%', order: 3, isExtensible: true }, isExtensible: true, }, groups: { @@ -19,8 +19,8 @@ const startingDoc = { }, defaultWebViewTopMenu: { columns: { - 'platform.project': { label: '%webView_Project%', order: 1 }, - 'platform.edit': { label: '%webView_Edit%', order: 2, isExtensible: true }, + 'platform.project': { label: '%webView_menuItemName_project%', order: 1 }, + 'platform.edit': { label: '%webView_menuItemName_edit%', order: 2, isExtensible: true }, }, groups: { 'platform.projectTop': { column: 'platform.project', order: 1 }, @@ -54,14 +54,14 @@ const startingDoc = { }, items: [ { - label: '%insertNote%', + label: '%general_insertNote%', localizeNotes: 'Web view context menu > Insert note...', group: 'platform.insert', order: 1, command: 'platform.insertNote', }, { - label: '%wordList%', + label: '%menuItemName_wordList%', localizeNotes: 'Web view context menu > Word list...', group: 'platform.wordList', order: 1, @@ -195,9 +195,9 @@ const expectedOutput = { mainMenu: { columns: { 'paratext.paratext': { label: '%mainMenu_Paratext%', order: 0 }, - 'platform.window': { label: '%mainMenu_Window%', order: 1 }, - 'platform.layout': { label: '%mainMenu_Layout%', order: 2 }, - 'platform.help': { label: '%mainMenu_Help%', order: 3, isExtensible: true }, + 'platform.window': { label: '%mainMenu_menuItemName_window%', order: 1 }, + 'platform.layout': { label: '%mainMenu_menuItemName_layout%', order: 2 }, + 'platform.help': { label: '%mainMenu_menuItemName_help%', order: 3, isExtensible: true }, isExtensible: true, }, groups: { @@ -284,8 +284,8 @@ const expectedOutput = { }, defaultWebViewTopMenu: { columns: { - 'platform.project': { label: '%webView_Project%', order: 1 }, - 'platform.edit': { label: '%webView_Edit%', order: 2, isExtensible: true }, + 'platform.project': { label: '%webView_menuItemName_project%', order: 1 }, + 'platform.edit': { label: '%webView_menuItemName_edit%', order: 2, isExtensible: true }, }, groups: { 'platform.projectTop': { column: 'platform.project', order: 1 }, @@ -319,14 +319,14 @@ const expectedOutput = { }, items: [ { - label: '%insertNote%', + label: '%general_insertNote%', localizeNotes: 'Web view context menu > Insert note...', group: 'platform.insert', order: 1, command: 'platform.insertNote', }, { - label: '%wordList%', + label: '%menuItemName_wordList%', localizeNotes: 'Web view context menu > Word list...', group: 'platform.wordList', order: 1, diff --git a/src/shared/utils/project-settings-document-combiner.test.ts b/src/shared/utils/project-settings-document-combiner.test.ts index 459091a652..8b0009bcbf 100644 --- a/src/shared/utils/project-settings-document-combiner.test.ts +++ b/src/shared/utils/project-settings-document-combiner.test.ts @@ -19,16 +19,16 @@ jest.mock('@shared/services/localization.service', () => ({ /** Info about all settings built into core. Does not contain info for extensions' settings */ const platformSettings: ProjectSettingsContribution = { - label: '%project_settings_platform_group1_label%', + label: '%project_settings_platform_settingName_group1%', description: '%project_settings_platform_group1_description%', properties: { 'platform.fullName': { - label: '%project_settings_platform_fullName_label%', - default: '%project_full_name_missing%', + label: '%project_settings_platform_settingName_fullName%', + default: '%project_settings_platform_defaultFullName_nameMissing%', }, 'platform.language': { - label: '%project_settings_platform_language_label%', - default: '%project_language_missing%', + label: '%project_settings_platform_settingName_language%', + default: '%project_settings_platform_defaultLanguage_languageMissing%', }, }, }; diff --git a/src/shared/utils/settings-document-combiner.test.ts b/src/shared/utils/settings-document-combiner.test.ts index cbd1705c7b..98b694ccba 100644 --- a/src/shared/utils/settings-document-combiner.test.ts +++ b/src/shared/utils/settings-document-combiner.test.ts @@ -24,11 +24,11 @@ const platformSettings: SettingsContribution = { description: '%platform_group1_description%', properties: { 'platform.verseRef': { - label: '%settings_platform_verseRef_label%', + label: '%settings_platform_settingName_verseRef%', default: { bookNum: 1, chapterNum: 1, verseNum: 1 }, }, 'platform.interfaceLanguage': { - label: '%settings_platform_interfaceLanguage_label%', + label: '%settings_platform_settingName_interfaceLanguage%', default: ['eng'], }, },