From 5ce472fec693de462c4ce6ce78b694b81a45d40f Mon Sep 17 00:00:00 2001 From: sebastien Date: Fri, 31 Jan 2025 12:37:09 +0100 Subject: [PATCH] minor refactor --- .../docusaurus-plugin-content-docs/src/cli.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/docusaurus-plugin-content-docs/src/cli.ts b/packages/docusaurus-plugin-content-docs/src/cli.ts index c07b1d69d4b2..e66e910ebc18 100644 --- a/packages/docusaurus-plugin-content-docs/src/cli.ts +++ b/packages/docusaurus-plugin-content-docs/src/cli.ts @@ -126,22 +126,19 @@ async function cliDocsVersionCommand( await fs.copy(docsDir, newVersionDir); // Copy version JSON translation file for this locale + // i18n//docusaurus-plugin-content-docs/current.json => version-v1.json + // See https://docusaurus.io/docs/next/api/plugins/@docusaurus/plugin-content-docs#translation-files-location if (locale !== i18n.defaultLocale) { - const pluginDir = getPluginDirPathLocalized({ + const dir = getPluginDirPathLocalized({ localizationDir, pluginId, }); - - const currentI18nPath = path.join(pluginDir, 'current.json'); - const versionedI18nPath = path.join( - pluginDir, - `version-${version}.json`, - ); - - if (await fs.pathExists(currentI18nPath)) { - await fs.copy(currentI18nPath, versionedI18nPath); + const sourceFile = path.join(dir, 'current.json'); + const dest = path.join(dir, `version-${version}.json`); + if (await fs.pathExists(sourceFile)) { + await fs.copy(sourceFile, dest); } else { - logger.warn`${pluginIdLogPrefix}: i18n resource file does not exist in path=${currentI18nPath}. Skipping.`; + logger.warn`${pluginIdLogPrefix}: i18n translation file does not exist in path=${sourceFile}. Skipping.`; } } }),