1
0

merge translations (based part)

This commit is contained in:
piuvas
2024-10-07 20:38:42 -03:00
parent 5145afb625
commit 6f7c0c2de3
3 changed files with 1031 additions and 769 deletions
+5 -2
View File
@@ -5,7 +5,7 @@
import * as fs from 'node:fs';
import * as yaml from 'js-yaml';
const merge = (...args) => args.reduce((a, c) => ({
export const merge = (...args) => args.reduce((a, c) => ({
...a,
...c,
...Object.entries(a)
@@ -60,7 +60,10 @@ export function build() {
// https://github.com/vitest-dev/vitest/issues/3988#issuecomment-1686599577
// https://github.com/misskey-dev/misskey/pull/14057#issuecomment-2192833785
const metaUrl = import.meta.url;
const locales = languages.reduce((a, c) => (a[c] = yaml.load(clean(fs.readFileSync(new URL(`${c}.yml`, metaUrl), 'utf-8'))) || {}, a), {});
const sharkeyLocales = languages.reduce((a, c) => (a[c] = yaml.load(clean(fs.readFileSync(new URL(`../sharkey-locales/${c}.yml`, metaUrl), 'utf-8'))) || {}, a), {});
const misskeyLocales = languages.reduce((a, c) => (a[c] = yaml.load(clean(fs.readFileSync(new URL(`${c}.yml`, metaUrl), 'utf-8'))) || {}, a), {});
// merge sharkey and misskey's locales. the second argument (sharkey) overwrites the first argument (misskey).
const locales = merge(misskeyLocales, sharkeyLocales);
// 空文字列が入ることがあり、フォールバックが動作しなくなるのでプロパティごと消す
const removeEmpty = (obj) => {