From 7e3c34495e1e4dde7fdbc6f09bfd4f007f808da1 Mon Sep 17 00:00:00 2001 From: CherryKitten Date: Tue, 29 Nov 2022 01:05:16 +0100 Subject: [PATCH] Add custom locales --- .gitignore | 1 + locales/index.js | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a4e0313996..fcab9e323e 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 3be17d471e..94643a76ee 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] = (() => {