mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-19 03:02:30 +02:00
feat(core): allow customizing the i18n directory path (#7386)
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
c07a514730
commit
abe5450526
26 changed files with 147 additions and 166 deletions
|
@ -55,19 +55,19 @@ exports[`docusaurus-plugin-content-pages loads simple pages 1`] = `
|
|||
exports[`docusaurus-plugin-content-pages loads simple pages with french translations 1`] = `
|
||||
[
|
||||
{
|
||||
"permalink": "/",
|
||||
"permalink": "/fr/",
|
||||
"source": "@site/src/pages/index.js",
|
||||
"type": "jsx",
|
||||
},
|
||||
{
|
||||
"permalink": "/typescript",
|
||||
"permalink": "/fr/typescript",
|
||||
"source": "@site/src/pages/typescript.tsx",
|
||||
"type": "jsx",
|
||||
},
|
||||
{
|
||||
"description": "Markdown index page",
|
||||
"frontMatter": {},
|
||||
"permalink": "/hello/",
|
||||
"permalink": "/fr/hello/",
|
||||
"source": "@site/src/pages/hello/index.md",
|
||||
"title": "Index",
|
||||
"type": "mdx",
|
||||
|
@ -78,26 +78,26 @@ exports[`docusaurus-plugin-content-pages loads simple pages with french translat
|
|||
"description": "my mdx page",
|
||||
"title": "mdx page",
|
||||
},
|
||||
"permalink": "/hello/mdxPage",
|
||||
"permalink": "/fr/hello/mdxPage",
|
||||
"source": "@site/src/pages/hello/mdxPage.mdx",
|
||||
"title": "mdx page",
|
||||
"type": "mdx",
|
||||
},
|
||||
{
|
||||
"permalink": "/hello/translatedJs",
|
||||
"permalink": "/fr/hello/translatedJs",
|
||||
"source": "@site/i18n/fr/docusaurus-plugin-content-pages/hello/translatedJs.js",
|
||||
"type": "jsx",
|
||||
},
|
||||
{
|
||||
"description": "translated markdown page (fr)",
|
||||
"frontMatter": {},
|
||||
"permalink": "/hello/translatedMd",
|
||||
"permalink": "/fr/hello/translatedMd",
|
||||
"source": "@site/i18n/fr/docusaurus-plugin-content-pages/hello/translatedMd.md",
|
||||
"title": undefined,
|
||||
"type": "mdx",
|
||||
},
|
||||
{
|
||||
"permalink": "/hello/world",
|
||||
"permalink": "/fr/hello/world",
|
||||
"source": "@site/src/pages/hello/world.js",
|
||||
"type": "jsx",
|
||||
},
|
||||
|
|
|
@ -32,15 +32,9 @@ describe('docusaurus-plugin-content-pages', () => {
|
|||
|
||||
it('loads simple pages with french translations', async () => {
|
||||
const siteDir = path.join(__dirname, '__fixtures__', 'website');
|
||||
const context = await loadContext({siteDir});
|
||||
const context = await loadContext({siteDir, locale: 'fr'});
|
||||
const plugin = pluginContentPages(
|
||||
{
|
||||
...context,
|
||||
i18n: {
|
||||
...context.i18n,
|
||||
currentLocale: 'fr',
|
||||
},
|
||||
},
|
||||
context,
|
||||
validateOptions({
|
||||
validate: normalizePluginOptions,
|
||||
options: {
|
||||
|
|
|
@ -48,18 +48,12 @@ export default function pluginContentPages(
|
|||
[admonitions, options.admonitions],
|
||||
]);
|
||||
}
|
||||
const {
|
||||
siteConfig,
|
||||
siteDir,
|
||||
generatedFilesDir,
|
||||
i18n: {currentLocale},
|
||||
} = context;
|
||||
const {siteConfig, siteDir, generatedFilesDir, localizationDir} = context;
|
||||
|
||||
const contentPaths: PagesContentPaths = {
|
||||
contentPath: path.resolve(siteDir, options.path),
|
||||
contentPathLocalized: getPluginI18nPath({
|
||||
siteDir,
|
||||
locale: currentLocale,
|
||||
localizationDir,
|
||||
pluginName: 'docusaurus-plugin-content-pages',
|
||||
pluginId: options.id,
|
||||
}),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue