mirror of
https://github.com/yannbertrand/macos-defaults
synced 2024-12-15 06:02:40 +00:00
30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
const fs = require('fs')
|
|
const YAML = require('yaml')
|
|
|
|
const writeTree = require('./write-tree')
|
|
const writeConfig = require('./write-config')
|
|
|
|
const input = fs.readFileSync('../../defaults.yml', 'utf8')
|
|
const inputFr = fs.readFileSync('../../defaults-fr.yml', 'utf8')
|
|
const defaults = YAML.parse(input)
|
|
const defaultsFr = YAML.parse(inputFr)
|
|
|
|
const templatesPath = 'templates'
|
|
const destinationPath = 'docs'
|
|
|
|
const supportedLanguages = {
|
|
languages: [
|
|
{ url: '/fr/', lang: 'fr-FR', home: 'Accueil', defaults: getSafeDefaults(defaultsFr, defaults), isFallback: false },
|
|
{ url: '/', lang: 'en-US', home: 'Home', defaults: defaults, isFallback: true },
|
|
]
|
|
}
|
|
|
|
supportedLanguages.languages.forEach((supportedLanguage) => {
|
|
const { url, isFallback } = supportedLanguage
|
|
writeTree(supportedLanguage, `${templatesPath}${url}`, `${destinationPath}${url}`)
|
|
writeConfig(supportedLanguage, supportedLanguages, `${templatesPath}${url}`, `${destinationPath}${url}`, isFallback)
|
|
})
|
|
|
|
function getSafeDefaults(localizedDefaults, fallbackDefaults) {
|
|
return { ...fallbackDefaults, ...localizedDefaults }
|
|
}
|