diff --git a/.gitignore b/.gitignore index a4e031399..fcab9e323 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,7 @@ api-docs.json ormconfig.json /custom packages/backend/assets/instance.css +/locales/custom # blender backups *.blend1 diff --git a/locales/index.js b/locales/index.js index 3be17d471..94643a76e 100644 --- a/locales/index.js +++ b/locales/index.js @@ -4,6 +4,8 @@ const fs = require('fs'); const yaml = require('js-yaml'); +let languages = [] +let languages_custom = [] const merge = (...args) => args.reduce((a, c) => ({ ...a, @@ -13,12 +15,18 @@ const merge = (...args) => args.reduce((a, c) => ({ .reduce((a, [k, v]) => (a[k] = merge(v, c[k]), a), {}) }), {}); -languages = [] fs.readdirSync(__dirname).forEach((file) => { if (file.includes('.yml')){ file = file.slice(0, file.indexOf('.')) - languages.push(file) + languages.push(file); + } +}) + +fs.readdirSync(__dirname + '/custom').forEach((file) => { + if (file.includes('.yml')){ + file = file.slice(0, file.indexOf('.')) + languages_custom.push(file); } }) @@ -32,6 +40,8 @@ const primaries = { const clean = (text) => text.replace(new RegExp(String.fromCodePoint(0x08), 'g'), ''); const locales = languages.reduce((a, c) => (a[c] = yaml.load(clean(fs.readFileSync(`${__dirname}/${c}.yml`, 'utf-8'))) || {}, a), {}); +const locales_custom = languages_custom.reduce((a, c) => (a[c] = yaml.load(clean(fs.readFileSync(`${__dirname}/custom/${c}.yml`, 'utf-8'))) || {}, a), {}); +Object.assign(locales, locales_custom) module.exports = Object.entries(locales) .reduce((a, [k ,v]) => (a[k] = (() => {