mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-28 07:27:49 +02:00
fix(docs): versioning CLI should copy localized translation file current.json
to version-<v>.json
(#10875)
Co-authored-by: Sungchang Ha <bryan98@naver.com>
This commit is contained in:
parent
bc3445c344
commit
3b72bb43db
4 changed files with 36 additions and 0 deletions
|
@ -14,6 +14,7 @@ import {
|
|||
getVersionDocsDirPath,
|
||||
getVersionSidebarsPath,
|
||||
getDocsDirPathLocalized,
|
||||
getPluginDirPathLocalized,
|
||||
readVersionsFile,
|
||||
} from './versions/files';
|
||||
import {validateVersionName} from './versions/validation';
|
||||
|
@ -123,6 +124,23 @@ async function cliDocsVersionCommand(
|
|||
versionName: version,
|
||||
});
|
||||
await fs.copy(docsDir, newVersionDir);
|
||||
|
||||
// Copy version JSON translation file for this locale
|
||||
// i18n/<l>/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 dir = getPluginDirPathLocalized({
|
||||
localizationDir,
|
||||
pluginId,
|
||||
});
|
||||
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 translation file does not exist in path=${sourceFile}. Skipping.`;
|
||||
}
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue