Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrong sidebar_label and title on versioned_docs #1265

Merged
merged 2 commits into from
Mar 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions v1/lib/write-translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,13 @@ function execute() {
// look through markdown headers of docs for titles and categories to translate
const docsDir = nodePath.join(CWD, '../', readMetadata.getDocsPath());
const versionedDocsDir = nodePath.join(CWD, 'versioned_docs');
let files = [
...glob.sync(`${docsDir}/**`),
...glob.sync(`${versionedDocsDir}/**`),
];
files.forEach(file => {

const translateDoc = (file, refDir) => {
const extension = nodePath.extname(file);
if (extension === '.md' || extension === '.markdown') {
let res;
try {
res = readMetadata.processMetadata(file, docsDir);
res = readMetadata.processMetadata(file, refDir);
} catch (e) {
console.error(e);
process.exit(1);
Expand All @@ -100,7 +97,12 @@ function execute() {
metadata.sidebar_label;
}
}
});
};
glob.sync(`${docsDir}/**`).forEach(file => translateDoc(file, docsDir));
glob
.sync(`${versionedDocsDir}/**`)
.forEach(file => translateDoc(file, versionedDocsDir));

// look through header links for text to translate
siteConfig.headerLinks.forEach(link => {
if (link.label) {
Expand All @@ -116,8 +118,7 @@ function execute() {
});
});

files = glob.sync(`${CWD}/versioned_sidebars/*`);
files.forEach(file => {
glob.sync(`${CWD}/versioned_sidebars/*`).forEach(file => {
if (!file.endsWith('-sidebars.json')) {
if (file.endsWith('-sidebar.json')) {
console.warn(
Expand All @@ -143,8 +144,7 @@ function execute() {
});

// go through pages to look for text inside translate tags
files = glob.sync(`${CWD}/pages/en/**`);
files.forEach(file => {
glob.sync(`${CWD}/pages/en/**`).forEach(file => {
const extension = nodePath.extname(file);
if (extension === '.js') {
const ast = babylon.parse(fs.readFileSync(file, 'utf8'), {
Expand Down