mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-30 10:48:05 +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
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"some.key": "some translation"
|
||||||
|
}
|
Binary file not shown.
|
@ -14,6 +14,7 @@ import {
|
||||||
getVersionDocsDirPath,
|
getVersionDocsDirPath,
|
||||||
getVersionSidebarsPath,
|
getVersionSidebarsPath,
|
||||||
getDocsDirPathLocalized,
|
getDocsDirPathLocalized,
|
||||||
|
getPluginDirPathLocalized,
|
||||||
readVersionsFile,
|
readVersionsFile,
|
||||||
} from './versions/files';
|
} from './versions/files';
|
||||||
import {validateVersionName} from './versions/validation';
|
import {validateVersionName} from './versions/validation';
|
||||||
|
@ -123,6 +124,23 @@ async function cliDocsVersionCommand(
|
||||||
versionName: version,
|
versionName: version,
|
||||||
});
|
});
|
||||||
await fs.copy(docsDir, newVersionDir);
|
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.`;
|
||||||
|
}
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,21 @@ export function getDocsDirPathLocalized({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getPluginDirPathLocalized({
|
||||||
|
localizationDir,
|
||||||
|
pluginId,
|
||||||
|
}: {
|
||||||
|
localizationDir: string;
|
||||||
|
pluginId: string;
|
||||||
|
}): string {
|
||||||
|
return getPluginI18nPath({
|
||||||
|
localizationDir,
|
||||||
|
pluginName: 'docusaurus-plugin-content-docs',
|
||||||
|
pluginId,
|
||||||
|
subPaths: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/** `community` => `[siteDir]/community_versions.json` */
|
/** `community` => `[siteDir]/community_versions.json` */
|
||||||
export function getVersionsFilePath(siteDir: string, pluginId: string): string {
|
export function getVersionsFilePath(siteDir: string, pluginId: string): string {
|
||||||
return path.join(siteDir, addPluginIdPrefix(VERSIONS_JSON_FILE, pluginId));
|
return path.join(siteDir, addPluginIdPrefix(VERSIONS_JSON_FILE, pluginId));
|
||||||
|
|
Loading…
Add table
Reference in a new issue