From ffdf8262d713a58c0bbd5d343e9a85341ec08fb7 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Sat, 11 Nov 2023 12:33:55 -0800 Subject: [PATCH] Localization updates --- l10n/bundle.l10n.json | 38 ++++++- scripts/generate-localization-enum.js | 9 +- src/constants/settings.ts | 2 +- src/extension.ts | 4 +- src/listeners/dashboard/DashboardListener.ts | 26 ++++- src/listeners/dashboard/SettingsListener.ts | 14 ++- src/listeners/dashboard/SnippetListener.ts | 14 ++- src/listeners/general/GitListener.ts | 10 +- src/listeners/panel/DataListener.ts | 14 ++- src/listeners/panel/TaxonomyListener.ts | 8 +- src/localization/localization.enum.ts | 100 ++++++++++++++++++- src/providers/MarkdownFoldingProvider.ts | 3 +- src/services/ModeSwitch.ts | 21 ++-- src/services/PagesParser.ts | 13 ++- src/services/SponsorAI.ts | 10 +- src/services/Terminal.ts | 6 +- 16 files changed, 248 insertions(+), 44 deletions(-) diff --git a/l10n/bundle.l10n.json b/l10n/bundle.l10n.json index 99480483..e2117a0e 100644 --- a/l10n/bundle.l10n.json +++ b/l10n/bundle.l10n.json @@ -319,7 +319,7 @@ "dashboard.media.detailsSlideOver.unmapped.description": "Do you want to remap the metadata of unmapped files?", "dashboard.configuration.astro.astroContentTypes.empty": "No Astro Content Collections found.", - "dashboard.configuration.astro.astroContentTypes.description": "The following Astro Content Collections and can be used to generate a content-type.", + "dashboard.configuration.astro.astroContentTypes.description": "The following Astro Content Collections can be used to generate a content-type.", "panel.contentType.contentTypeValidator.title": "Content-type", "panel.contentType.contentTypeValidator.hint": "We noticed field differences between the content-type and the front matter data. \n Would you like to create, update, or set the content-type for this content?", @@ -668,5 +668,39 @@ "helpers.taxonomyHelper.move.progress.title": "{0}: Moving \"{1}\" from {2} to \"${3}\".", "helpers.taxonomyHelper.move.success": "Move completed.", - "listeners.dashboard.settingsListener.triggerTemplate.notification": "Template files copied." + "listeners.dashboard.dashboardListener.pinItem.noPath.error": "No path provided.", + "listeners.dashboard.dashboardListener.pinItem.coundNotPin.error": "Could not pin item.", + "listeners.dashboard.dashboardListener.pinItem.coundNotUnPin.error": "Could not unpin item.", + + "listeners.dashboard.settingsListener.triggerTemplate.notification": "Template files copied.", + "listeners.dashboard.settingsListener.triggerTemplate.progress.title": "Downloading and initializing the template...", + "listeners.dashboard.settingsListener.triggerTemplate.download.error": "Failed to download the template.", + "listeners.dashboard.settingsListener.triggerTemplate.init.error": "Failed to initialize the template.", + + "listeners.dashboard.snippetListener.addSnippet.missingFields.warning": "Snippet missing title or body", + "listeners.dashboard.snippetListener.addSnippet.exists.warning": "Snippet with the same title already exists", + "listeners.dashboard.snippetListener.updateSnippet.noSnippets.warning": "No snippets to update", + + "listeners.general.gitListener.push.error": "Failed to push submodules.", + + "listeners.panel.dataListener.aiSuggestTaxonomy.noEditor.error": "No active editor", + "listeners.panel.dataListener.aiSuggestTaxonomy.noData.error": "No article data", + "listeners.panel.dataListener.getDataFileEntries.noDataFiles.error": "Couldn't find data file entries", + + + "listeners.panel.taxonomyListener.aiSuggestTaxonomy.noEditor.error": "No active editor", + "listeners.panel.taxonomyListener.aiSuggestTaxonomy.noData.error": "No article data", + + "services.modeSwitch.switchMode.quickPick.placeholder": "Select the mode you want to use", + "services.modeSwitch.switchMode.quickPick.title": "{0}: Mode selection", + "services.modeSwitch.setText.mode": "Mode: {0}", + + "services.pagesParser.parsePages.statusBar.text": "Processing...", + "services.pagesParser.parsePages.file.error": "File error: {0}", + + "services.sponsorAi.getTitles.warning": "The AI title generation took too long. Please try again later.", + "services.sponsorAi.getDescription.warning": "The AI description generation took too long. Please try again later.", + "services.sponsorAi.getTaxonomySuggestions.warning": "The AI taxonomy generation took too long. Please try again later.", + + "services.terminal.openLocalServerTerminal.terminalOption.message": "Starting local server" } \ No newline at end of file diff --git a/scripts/generate-localization-enum.js b/scripts/generate-localization-enum.js index d15f5735..126dde0a 100644 --- a/scripts/generate-localization-enum.js +++ b/scripts/generate-localization-enum.js @@ -1,5 +1,6 @@ const fs = require('fs'); const path = require('path'); +const jsoncParser = require('jsonc-parser'); const camlCase = (str) => { const words = str.split('.'); @@ -15,12 +16,14 @@ const camlCase = (str) => { const enFile = fs.readFileSync(path.join(__dirname, '../l10n/bundle.l10n.json'), 'utf8'); // Parse the EN file - const en = JSON.parse(enFile); + const en = jsoncParser.parse(enFile); const keys = Object.keys(en); // Create an enum file - const enumFile = fs.createWriteStream(path.join(__dirname, '../src/localization/localization.enum.ts')); + const enumFile = fs.createWriteStream( + path.join(__dirname, '../src/localization/localization.enum.ts') + ); // Write the enum file header enumFile.write(`export enum LocalizationKey {\n`); @@ -38,4 +41,4 @@ const camlCase = (str) => { // Close the enum file enumFile.close(); -})(); \ No newline at end of file +})(); diff --git a/src/constants/settings.ts b/src/constants/settings.ts index 02a818b8..dbde401b 100644 --- a/src/constants/settings.ts +++ b/src/constants/settings.ts @@ -1,4 +1,4 @@ -export const EXTENSION_NAME = 'π–₯π—‹π—ˆπ—‡π— 𝖬𝖺𝗍𝗍𝖾𝗋 𝖒𝖬𝖲'; +export const EXTENSION_NAME = 'Front Matter CMS'; export const CONFIG_KEY = 'frontMatter'; diff --git a/src/extension.ts b/src/extension.ts index 8cd35737..f88b54d7 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,6 +1,6 @@ import { GitListener } from './listeners/general/GitListener'; import * as vscode from 'vscode'; -import { COMMAND_NAME, TelemetryEvent } from './constants'; +import { COMMAND_NAME, EXTENSION_NAME, TelemetryEvent } from './constants'; import { MarkdownFoldingProvider } from './providers/MarkdownFoldingProvider'; import { TagType } from './panelWebView/TagType'; import { PanelProvider } from './panelWebView/PanelProvider'; @@ -281,7 +281,7 @@ export async function activate(context: vscode.ExtensionContext) { ); fmStatusBarItem.command = COMMAND_NAME.dashboard; fmStatusBarItem.text = `$(fm-logo)`; - fmStatusBarItem.tooltip = `Front Matter CMS`; + fmStatusBarItem.tooltip = EXTENSION_NAME; fmStatusBarItem.show(); // Register listeners that make sure the status bar updates diff --git a/src/listeners/dashboard/DashboardListener.ts b/src/listeners/dashboard/DashboardListener.ts index 0ba85e54..21870a40 100644 --- a/src/listeners/dashboard/DashboardListener.ts +++ b/src/listeners/dashboard/DashboardListener.ts @@ -6,6 +6,8 @@ import { Extension, Notifications } from '../../helpers'; import { PostMessageData } from '../../models'; import { PinnedItems } from '../../services'; import { BaseListener } from './BaseListener'; +import * as l10n from '@vscode/l10n'; +import { LocalizationKey } from '../../localization'; export class DashboardListener extends BaseListener { /** @@ -66,14 +68,22 @@ export class DashboardListener extends BaseListener { const path = payload; if (!path) { - this.sendError(command as any, requestId, 'No path provided.'); + this.sendError( + command as any, + requestId, + l10n.t(LocalizationKey.listenersDashboardDashboardListenerPinItemNoPathError) + ); return; } const allPinned = await PinnedItems.pin(path); if (!allPinned) { - this.sendError(command as any, requestId, 'Could not pin item.'); + this.sendError( + command as any, + requestId, + l10n.t(LocalizationKey.listenersDashboardDashboardListenerPinItemCoundNotPinError) + ); return; } @@ -92,14 +102,22 @@ export class DashboardListener extends BaseListener { const path = payload; if (!path) { - this.sendError(command as any, requestId, 'No path provided.'); + this.sendError( + command as any, + requestId, + l10n.t(LocalizationKey.listenersDashboardDashboardListenerPinItemNoPathError) + ); return; } const updatedPinned = await PinnedItems.remove(path); if (!updatedPinned) { - this.sendError(command as any, requestId, 'Could not unpin item.'); + this.sendError( + command as any, + requestId, + l10n.t(LocalizationKey.listenersDashboardDashboardListenerPinItemCoundNotUnPinError) + ); return; } diff --git a/src/listeners/dashboard/SettingsListener.ts b/src/listeners/dashboard/SettingsListener.ts index ad0a7375..bcbad6bc 100644 --- a/src/listeners/dashboard/SettingsListener.ts +++ b/src/listeners/dashboard/SettingsListener.ts @@ -201,7 +201,9 @@ export class SettingsListener extends BaseListener { await window.withProgress( { location: ProgressLocation.Notification, - title: 'Downloading and initializing the template...', + title: l10n.t( + LocalizationKey.listenersDashboardSettingsListenerTriggerTemplateProgressTitle + ), cancellable: false }, async (progress) => { @@ -209,7 +211,11 @@ export class SettingsListener extends BaseListener { const ghFolder = await download(template.url, wsFolder.fsPath); if (!ghFolder.downloaded) { - Notifications.error('Failed to download the template.'); + Notifications.error( + l10n.t( + LocalizationKey.listenersDashboardSettingsListenerTriggerTemplateDownloadError + ) + ); return; } @@ -225,7 +231,9 @@ export class SettingsListener extends BaseListener { ); } } catch (e) { - Notifications.error(`Failed to initialize the template.`); + Notifications.error( + l10n.t(LocalizationKey.listenersDashboardSettingsListenerTriggerTemplateInitError) + ); } } ); diff --git a/src/listeners/dashboard/SnippetListener.ts b/src/listeners/dashboard/SnippetListener.ts index 5c699a0f..56572285 100644 --- a/src/listeners/dashboard/SnippetListener.ts +++ b/src/listeners/dashboard/SnippetListener.ts @@ -7,6 +7,8 @@ import { Notifications, Settings, Telemetry } from '../../helpers'; import { PostMessageData, Snippets } from '../../models'; import { BaseListener } from './BaseListener'; import { SettingsListener } from './SettingsListener'; +import * as l10n from '@vscode/l10n'; +import { LocalizationKey } from '../../localization'; export class SnippetListener extends BaseListener { public static process(msg: PostMessageData) { @@ -30,13 +32,17 @@ export class SnippetListener extends BaseListener { const { title, description, body, fields, isMediaSnippet } = data; if (!title || !body) { - Notifications.warning('Snippet missing title or body'); + Notifications.warning( + l10n.t(LocalizationKey.listenersDashboardSnippetListenerAddSnippetMissingFieldsWarning) + ); return; } const snippets = Settings.get(SETTING_CONTENT_SNIPPETS); if (snippets && snippets[title]) { - Notifications.warning('Snippet with the same title already exists'); + Notifications.warning( + l10n.t(LocalizationKey.listenersDashboardSnippetListenerAddSnippetExistsWarning) + ); return; } @@ -63,7 +69,9 @@ export class SnippetListener extends BaseListener { const { snippets } = data; if (!snippets) { - Notifications.warning('No snippets to update'); + Notifications.warning( + l10n.t(LocalizationKey.listenersDashboardSnippetListenerUpdateSnippetNoSnippetsWarning) + ); return; } diff --git a/src/listeners/general/GitListener.ts b/src/listeners/general/GitListener.ts index 342f02fc..e4e76537 100644 --- a/src/listeners/general/GitListener.ts +++ b/src/listeners/general/GitListener.ts @@ -28,6 +28,8 @@ import { import { Folders } from '../../commands/Folders'; import { commands } from 'vscode'; import { PostMessageData } from '../../models'; +import * as l10n from '@vscode/l10n'; +import { LocalizationKey } from '../../localization'; export class GitListener { private static isRegistered: boolean = false; @@ -177,7 +179,9 @@ export class GitListener { } await subGit.push(); } catch (e) { - Notifications.error(`Failed to push submodules. Please check the logs for more details.`); + Notifications.errorWithOutput( + l10n.t(LocalizationKey.listenersGeneralGitListenerPushError) + ); Logger.error((e as Error).message); return; } @@ -203,7 +207,9 @@ export class GitListener { await git.subModule(['foreach', 'git', 'push']); } } catch (e) { - Notifications.error(`Failed to push submodules. Please check the logs for more details.`); + Notifications.errorWithOutput( + l10n.t(LocalizationKey.listenersGeneralGitListenerPushError) + ); Logger.error((e as Error).message); return; } diff --git a/src/listeners/panel/DataListener.ts b/src/listeners/panel/DataListener.ts index 9cde6738..c985bb09 100644 --- a/src/listeners/panel/DataListener.ts +++ b/src/listeners/panel/DataListener.ts @@ -24,6 +24,8 @@ import { PanelProvider } from '../../panelWebView/PanelProvider'; import { MessageHandlerData } from '@estruyf/vscode'; import { SponsorAi } from '../../services/SponsorAI'; import { Terminal } from '../../services'; +import * as l10n from '@vscode/l10n'; +import { LocalizationKey } from '../../localization'; const FILE_LIMIT = 10; @@ -94,7 +96,7 @@ export class DataListener extends BaseListener { panel.getWebview()?.postMessage({ command, requestId, - error: 'No active editor' + error: l10n.t(LocalizationKey.listenersPanelDataListenerAiSuggestTaxonomyNoEditorError) } as MessageHandlerData); return; } @@ -104,7 +106,7 @@ export class DataListener extends BaseListener { panel.getWebview()?.postMessage({ command, requestId, - error: 'No article data' + error: l10n.t(LocalizationKey.listenersPanelDataListenerAiSuggestTaxonomyNoDataError) } as MessageHandlerData); return; } @@ -126,7 +128,7 @@ export class DataListener extends BaseListener { panel.getWebview()?.postMessage({ command, requestId, - error: 'No article data' + error: l10n.t(LocalizationKey.listenersPanelDataListenerAiSuggestTaxonomyNoDataError) } as MessageHandlerData); return; } @@ -499,7 +501,11 @@ export class DataListener extends BaseListener { if (entries) { this.sendRequest(command, requestId, entries); } else { - this.sendRequestError(command, requestId, "Couldn't find data file entries"); + this.sendRequestError( + command, + requestId, + l10n.t(LocalizationKey.listenersPanelDataListenerGetDataFileEntriesNoDataFilesError) + ); } } diff --git a/src/listeners/panel/TaxonomyListener.ts b/src/listeners/panel/TaxonomyListener.ts index c6f16a1e..cf6cffd0 100644 --- a/src/listeners/panel/TaxonomyListener.ts +++ b/src/listeners/panel/TaxonomyListener.ts @@ -13,6 +13,8 @@ import { import { SponsorAi } from '../../services/SponsorAI'; import { PanelProvider } from '../../panelWebView/PanelProvider'; import { MessageHandlerData } from '@estruyf/vscode'; +import * as l10n from '@vscode/l10n'; +import { LocalizationKey } from '../../localization'; export class TaxonomyListener extends BaseListener { /** @@ -80,7 +82,7 @@ export class TaxonomyListener extends BaseListener { panel.getWebview()?.postMessage({ command, requestId, - error: 'No active editor' + error: l10n.t(LocalizationKey.listenersPanelTaxonomyListenerAiSuggestTaxonomyNoDataError) } as MessageHandlerData); return; } @@ -90,7 +92,7 @@ export class TaxonomyListener extends BaseListener { panel.getWebview()?.postMessage({ command, requestId, - error: 'No article data' + error: l10n.t(LocalizationKey.listenersPanelTaxonomyListenerAiSuggestTaxonomyNoEditorError) } as MessageHandlerData); return; } @@ -115,7 +117,7 @@ export class TaxonomyListener extends BaseListener { panel.getWebview()?.postMessage({ command, requestId, - error: 'No article data' + error: l10n.t(LocalizationKey.listenersPanelTaxonomyListenerAiSuggestTaxonomyNoDataError) } as MessageHandlerData); return; } diff --git a/src/localization/localization.enum.ts b/src/localization/localization.enum.ts index 35123382..2540df9e 100644 --- a/src/localization/localization.enum.ts +++ b/src/localization/localization.enum.ts @@ -1056,7 +1056,7 @@ export enum LocalizationKey { */ dashboardConfigurationAstroAstroContentTypesEmpty = 'dashboard.configuration.astro.astroContentTypes.empty', /** - * The following Astro Content Collections and can be used to generate a content-type. + * The following Astro Content Collections can be used to generate a content-type. */ dashboardConfigurationAstroAstroContentTypesDescription = 'dashboard.configuration.astro.astroContentTypes.description', /** @@ -2196,8 +2196,104 @@ export enum LocalizationKey { * Move completed. */ helpersTaxonomyHelperMoveSuccess = 'helpers.taxonomyHelper.move.success', + /** + * No path provided. + */ + listenersDashboardDashboardListenerPinItemNoPathError = 'listeners.dashboard.dashboardListener.pinItem.noPath.error', + /** + * Could not pin item. + */ + listenersDashboardDashboardListenerPinItemCoundNotPinError = 'listeners.dashboard.dashboardListener.pinItem.coundNotPin.error', + /** + * Could not unpin item. + */ + listenersDashboardDashboardListenerPinItemCoundNotUnPinError = 'listeners.dashboard.dashboardListener.pinItem.coundNotUnPin.error', /** * Template files copied. */ - listenersDashboardSettingsListenerTriggerTemplateNotification = 'listeners.dashboard.settingsListener.triggerTemplate.notification' + listenersDashboardSettingsListenerTriggerTemplateNotification = 'listeners.dashboard.settingsListener.triggerTemplate.notification', + /** + * Downloading and initializing the template... + */ + listenersDashboardSettingsListenerTriggerTemplateProgressTitle = 'listeners.dashboard.settingsListener.triggerTemplate.progress.title', + /** + * Failed to download the template. + */ + listenersDashboardSettingsListenerTriggerTemplateDownloadError = 'listeners.dashboard.settingsListener.triggerTemplate.download.error', + /** + * Failed to initialize the template. + */ + listenersDashboardSettingsListenerTriggerTemplateInitError = 'listeners.dashboard.settingsListener.triggerTemplate.init.error', + /** + * Snippet missing title or body + */ + listenersDashboardSnippetListenerAddSnippetMissingFieldsWarning = 'listeners.dashboard.snippetListener.addSnippet.missingFields.warning', + /** + * Snippet with the same title already exists + */ + listenersDashboardSnippetListenerAddSnippetExistsWarning = 'listeners.dashboard.snippetListener.addSnippet.exists.warning', + /** + * No snippets to update + */ + listenersDashboardSnippetListenerUpdateSnippetNoSnippetsWarning = 'listeners.dashboard.snippetListener.updateSnippet.noSnippets.warning', + /** + * Failed to push submodules. + */ + listenersGeneralGitListenerPushError = 'listeners.general.gitListener.push.error', + /** + * No active editor + */ + listenersPanelDataListenerAiSuggestTaxonomyNoEditorError = 'listeners.panel.dataListener.aiSuggestTaxonomy.noEditor.error', + /** + * No article data + */ + listenersPanelDataListenerAiSuggestTaxonomyNoDataError = 'listeners.panel.dataListener.aiSuggestTaxonomy.noData.error', + /** + * Couldn't find data file entries + */ + listenersPanelDataListenerGetDataFileEntriesNoDataFilesError = 'listeners.panel.dataListener.getDataFileEntries.noDataFiles.error', + /** + * No active editor + */ + listenersPanelTaxonomyListenerAiSuggestTaxonomyNoEditorError = 'listeners.panel.taxonomyListener.aiSuggestTaxonomy.noEditor.error', + /** + * No article data + */ + listenersPanelTaxonomyListenerAiSuggestTaxonomyNoDataError = 'listeners.panel.taxonomyListener.aiSuggestTaxonomy.noData.error', + /** + * Select the mode you want to use + */ + servicesModeSwitchSwitchModeQuickPickPlaceholder = 'services.modeSwitch.switchMode.quickPick.placeholder', + /** + * {0}: Mode selection + */ + servicesModeSwitchSwitchModeQuickPickTitle = 'services.modeSwitch.switchMode.quickPick.title', + /** + * Mode: {0} + */ + servicesModeSwitchSetTextMode = 'services.modeSwitch.setText.mode', + /** + * Processing... + */ + servicesPagesParserParsePagesStatusBarText = 'services.pagesParser.parsePages.statusBar.text', + /** + * File error: {0} + */ + servicesPagesParserParsePagesFileError = 'services.pagesParser.parsePages.file.error', + /** + * The AI title generation took too long. Please try again later. + */ + servicesSponsorAiGetTitlesWarning = 'services.sponsorAi.getTitles.warning', + /** + * The AI description generation took too long. Please try again later. + */ + servicesSponsorAiGetDescriptionWarning = 'services.sponsorAi.getDescription.warning', + /** + * The AI taxonomy generation took too long. Please try again later. + */ + servicesSponsorAiGetTaxonomySuggestionsWarning = 'services.sponsorAi.getTaxonomySuggestions.warning', + /** + * Starting local server + */ + servicesTerminalOpenLocalServerTerminalTerminalOptionMessage = 'services.terminal.openLocalServerTerminal.terminalOption.message' } diff --git a/src/providers/MarkdownFoldingProvider.ts b/src/providers/MarkdownFoldingProvider.ts index 8ea5656f..1811a8ee 100644 --- a/src/providers/MarkdownFoldingProvider.ts +++ b/src/providers/MarkdownFoldingProvider.ts @@ -18,8 +18,7 @@ import { } from 'vscode'; import { SETTING_CONTENT_FRONTMATTER_HIGHLIGHT, - SETTING_CONTENT_SUPPORTED_FILETYPES, - SETTING_FRONTMATTER_TYPE + SETTING_CONTENT_SUPPORTED_FILETYPES } from '../constants'; import { Settings } from '../helpers'; import { FrontMatterDecorationProvider } from './FrontMatterDecorationProvider'; diff --git a/src/services/ModeSwitch.ts b/src/services/ModeSwitch.ts index aeaef0e6..6314b180 100644 --- a/src/services/ModeSwitch.ts +++ b/src/services/ModeSwitch.ts @@ -1,9 +1,15 @@ import { ModeListener } from './../listeners/general/ModeListener'; -import { SETTING_GLOBAL_ACTIVE_MODE, SETTING_GLOBAL_MODES } from './../constants/settings'; -import { commands, StatusBarAlignment, StatusBarItem, ThemeColor, window } from 'vscode'; +import { + EXTENSION_NAME, + SETTING_GLOBAL_ACTIVE_MODE, + SETTING_GLOBAL_MODES +} from './../constants/settings'; +import { commands, StatusBarAlignment, StatusBarItem, window } from 'vscode'; import { Settings } from '../helpers/SettingsHelper'; import { COMMAND_NAME, CONTEXT } from '../constants'; import { Mode } from '../models'; +import * as l10n from '@vscode/l10n'; +import { LocalizationKey } from '../localization'; export class ModeSwitch { private static isInit: boolean = false; @@ -56,9 +62,9 @@ export class ModeSwitch { const modePicks = ['Default', ...modes.map((m) => m.id)]; const mode = await window.showQuickPick(modePicks, { - placeHolder: `Select the mode you want to use`, - ignoreFocusOut: true, - title: `Front Matter: Mode selection` + title: l10n.t(LocalizationKey.servicesModeSwitchSwitchModeQuickPickTitle, EXTENSION_NAME), + placeHolder: l10n.t(LocalizationKey.servicesModeSwitchSwitchModeQuickPickPlaceholder), + ignoreFocusOut: true }); if (mode) { @@ -70,9 +76,10 @@ export class ModeSwitch { } private static setText() { - ModeSwitch.statusBarElm.text = `$(preview) Mode: ${ + ModeSwitch.statusBarElm.text = `$(preview) ${l10n.t( + LocalizationKey.servicesModeSwitchSetTextMode, ModeSwitch.currentMode ? ModeSwitch.currentMode : 'Default' - }`; + )}`; ModeSwitch.statusBarElm.show(); } } diff --git a/src/services/PagesParser.ts b/src/services/PagesParser.ts index d3168a02..57ef1552 100644 --- a/src/services/PagesParser.ts +++ b/src/services/PagesParser.ts @@ -26,6 +26,8 @@ import { } from '../helpers'; import { existsAsync } from '../utils'; import { Article, Cache } from '../commands'; +import * as l10n from '@vscode/l10n'; +import { LocalizationKey } from '../localization'; export class PagesParser { public static allPages: Page[] = []; @@ -81,7 +83,9 @@ export class PagesParser { const pages: Page[] = []; if (folderInfo) { - PagesParser.pagesStatusBar.text = '$(sync~spin) Processing pages...'; + PagesParser.pagesStatusBar.text = `$(sync~spin) ${l10n.t( + LocalizationKey.servicesPagesParserParsePagesStatusBarText + )}`; PagesParser.pagesStatusBar.show(); for (const folder of folderInfo) { @@ -108,7 +112,12 @@ export class PagesParser { } Logger.error(`PagesParser::parsePages: ${file.filePath} - ${error.message}`); - Notifications.error(`File error: ${file.filePath} - ${error?.message || error}`); + Notifications.error( + l10n.t( + LocalizationKey.servicesPagesParserParsePagesFileError, + `${file.filePath} - ${error?.message || error}` + ) + ); } } } diff --git a/src/services/SponsorAI.ts b/src/services/SponsorAI.ts index bd8b4b35..0fb06db9 100644 --- a/src/services/SponsorAI.ts +++ b/src/services/SponsorAI.ts @@ -3,6 +3,8 @@ import { Logger, Notifications, Settings, TaxonomyHelper } from '../helpers'; import fetch from 'node-fetch'; import { TagType } from '../panelWebView/TagType'; import { TaxonomyType } from '../models'; +import * as l10n from '@vscode/l10n'; +import { LocalizationKey } from '../localization'; const AI_URL = 'https://frontmatter.codes/api/ai'; // const AI_URL = 'http://localhost:3000/api/ai'; @@ -18,7 +20,7 @@ export class SponsorAi { try { const controller = new AbortController(); const timeout = setTimeout(() => { - Notifications.warning(`The AI title generation took too long. Please try again later.`); + Notifications.warning(l10n.t(LocalizationKey.servicesSponsorAiGetTitlesWarning)); controller.abort(); }, 10000); const signal = controller.signal; @@ -51,7 +53,7 @@ export class SponsorAi { try { const controller = new AbortController(); const timeout = setTimeout(() => { - Notifications.warning(`The AI title generation took too long. Please try again later.`); + Notifications.warning(l10n.t(LocalizationKey.servicesSponsorAiGetDescriptionWarning)); controller.abort(); }, 10000); const signal = controller.signal; @@ -103,7 +105,9 @@ export class SponsorAi { try { const controller = new AbortController(); const timeout = setTimeout(() => { - Notifications.warning(`The AI taxonomy generation took too long. Please try again later.`); + Notifications.warning( + l10n.t(LocalizationKey.servicesSponsorAiGetTaxonomySuggestionsWarning) + ); controller.abort(); }, 10000); const signal = controller.signal; diff --git a/src/services/Terminal.ts b/src/services/Terminal.ts index 7b5c4ee3..ae17710d 100644 --- a/src/services/Terminal.ts +++ b/src/services/Terminal.ts @@ -1,6 +1,8 @@ import { workspace, window, ThemeIcon, TerminalOptions } from 'vscode'; import * as os from 'os'; import { Folders } from '../commands'; +import * as l10n from '@vscode/l10n'; +import { LocalizationKey } from '../localization'; interface ShellSetting { path: string; @@ -45,7 +47,9 @@ export class Terminal { const terminalOptions: TerminalOptions = { name: Terminal.terminalName, iconPath: new ThemeIcon('server-environment'), - message: `Starting local server` + message: l10n.t( + LocalizationKey.servicesTerminalOpenLocalServerTerminalTerminalOptionMessage + ) }; // Check if workspace