-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a42c8c6
commit 5dbbe81
Showing
148 changed files
with
10,956 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
VUE_APP_I18N_LOCALE=en | ||
VUE_APP_I18N_FALLBACK_LOCALE=en |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const fs = require('fs'); | ||
|
||
const localesMessages = { | ||
"fr": "Ce cookbook est aussi disponible [en Français]", | ||
"en": "This cookbook is also available [in English]" | ||
} | ||
|
||
const foreach = (arr, fn) => arr.map(fn).join('\n'); | ||
|
||
const generateIndex = (locale, relativePathToPages) => { | ||
const index = require(`../static/pages/${locale}/index.json`); | ||
return `## Index | ||
${foreach(index.chapters, chapter => ` | ||
### ${ chapter.title } | ||
${foreach(chapter.sections, section => | ||
`- [${section.title}](${relativePathToPages}/${locale}/${section.link}.md)` | ||
)}`)} | ||
${Object.keys(localesMessages) | ||
.filter(otherLocale => otherLocale !== locale) | ||
.map(otherLocale => `${localesMessages[otherLocale]}(${relativePathToPages}/${otherLocale}/index.md).`) | ||
.join('\n') | ||
}` | ||
} | ||
|
||
const replaceContent = (file, content) => { | ||
fs.writeFileSync(file, fs.readFileSync(file).toString().replace( | ||
/## Index[\s\S]*<!--- END_INDEX -->/, | ||
content + `\n\n<!--- END_INDEX -->`) | ||
); | ||
} | ||
|
||
replaceContent('README.md', generateIndex("en", "static/pages")) | ||
replaceContent('static/pages/en/index.md', generateIndex("en", "..")) | ||
replaceContent('static/pages/fr/index.md', generateIndex("fr", "..")) |
Oops, something went wrong.