mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-21 10:37:51 +02:00
Attempt to fix translation content conflict
This commit is contained in:
parent
dacfc17fb4
commit
7f05848713
8 changed files with 61 additions and 10 deletions
|
@ -48,8 +48,8 @@ function getSidebarTranslationFileContent(
|
||||||
|
|
||||||
const categories = collectSidebarCategories(sidebar);
|
const categories = collectSidebarCategories(sidebar);
|
||||||
|
|
||||||
const categoryContent: TranslationFileContent = Object.fromEntries(
|
const categoryEntries: TranslationMessageEntry[] = categories.flatMap(
|
||||||
categories.flatMap((category) => {
|
(category) => {
|
||||||
const entries: TranslationMessageEntry[] = [];
|
const entries: TranslationMessageEntry[] = [];
|
||||||
|
|
||||||
entries.push([
|
entries.push([
|
||||||
|
@ -82,9 +82,21 @@ function getSidebarTranslationFileContent(
|
||||||
}
|
}
|
||||||
|
|
||||||
return entries;
|
return entries;
|
||||||
}),
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
_.chain(categoryEntries)
|
||||||
|
.groupBy((entry) => entry[0])
|
||||||
|
.forEach((group, key) => {
|
||||||
|
if (group.length > 1) {
|
||||||
|
console.warn(`KEY CONFLICT FOR key = ${key}`, group.length);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.value();
|
||||||
|
|
||||||
|
const categoryContent: TranslationFileContent =
|
||||||
|
Object.fromEntries(categoryEntries);
|
||||||
|
|
||||||
const links = collectSidebarLinks(sidebar);
|
const links = collectSidebarLinks(sidebar);
|
||||||
const linksContent: TranslationFileContent = Object.fromEntries(
|
const linksContent: TranslationFileContent = Object.fromEntries(
|
||||||
links.map((link) => [
|
links.map((link) => [
|
||||||
|
|
|
@ -81,13 +81,16 @@ async function executePluginContentLoading({
|
||||||
plugin.loadContent?.(),
|
plugin.loadContent?.(),
|
||||||
);
|
);
|
||||||
|
|
||||||
content = await PerfLogger.async('translatePluginContent()', () =>
|
const translate = false;
|
||||||
translatePluginContent({
|
if (translate) {
|
||||||
plugin,
|
content = await PerfLogger.async('translatePluginContent()', () =>
|
||||||
content,
|
translatePluginContent({
|
||||||
context,
|
plugin,
|
||||||
}),
|
content,
|
||||||
);
|
context,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const defaultCodeTranslations =
|
const defaultCodeTranslations =
|
||||||
(await PerfLogger.async('getDefaultCodeTranslationMessages()', () =>
|
(await PerfLogger.async('getDefaultCodeTranslationMessages()', () =>
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"label": "Alpha",
|
||||||
|
"link": {
|
||||||
|
"type": "generated-index"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"label": "CategoryLabelTest",
|
||||||
|
"link": {
|
||||||
|
"type": "generated-index",
|
||||||
|
"title": "test category in Alpha",
|
||||||
|
"description": "Test description in Alpha"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
---
|
||||||
|
|
||||||
|
## Test file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"label": "Beta",
|
||||||
|
"link": {
|
||||||
|
"type": "generated-index"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"label": "CategoryLabelTest",
|
||||||
|
"link": {
|
||||||
|
"type": "generated-index",
|
||||||
|
"title": "test category in Beta",
|
||||||
|
"description": "Test description in Beta"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
---
|
||||||
|
|
||||||
|
## Test file
|
Loading…
Add table
Add a link
Reference in a new issue