Add custom locales
This commit is contained in:
parent
31af36e57e
commit
7e3c34495e
|
@ -52,6 +52,7 @@ api-docs.json
|
||||||
ormconfig.json
|
ormconfig.json
|
||||||
/custom
|
/custom
|
||||||
packages/backend/assets/instance.css
|
packages/backend/assets/instance.css
|
||||||
|
/locales/custom
|
||||||
|
|
||||||
# blender backups
|
# blender backups
|
||||||
*.blend1
|
*.blend1
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const yaml = require('js-yaml');
|
const yaml = require('js-yaml');
|
||||||
|
let languages = []
|
||||||
|
let languages_custom = []
|
||||||
|
|
||||||
const merge = (...args) => args.reduce((a, c) => ({
|
const merge = (...args) => args.reduce((a, c) => ({
|
||||||
...a,
|
...a,
|
||||||
|
@ -13,12 +15,18 @@ const merge = (...args) => args.reduce((a, c) => ({
|
||||||
.reduce((a, [k, v]) => (a[k] = merge(v, c[k]), a), {})
|
.reduce((a, [k, v]) => (a[k] = merge(v, c[k]), a), {})
|
||||||
}), {});
|
}), {});
|
||||||
|
|
||||||
languages = []
|
|
||||||
|
|
||||||
fs.readdirSync(__dirname).forEach((file) => {
|
fs.readdirSync(__dirname).forEach((file) => {
|
||||||
if (file.includes('.yml')){
|
if (file.includes('.yml')){
|
||||||
file = file.slice(0, file.indexOf('.'))
|
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 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 = 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)
|
module.exports = Object.entries(locales)
|
||||||
.reduce((a, [k ,v]) => (a[k] = (() => {
|
.reduce((a, [k ,v]) => (a[k] = (() => {
|
||||||
|
|
Loading…
Reference in New Issue