mirror of
https://codeberg.org/yeentown/barkey
synced 2024-12-22 13:00:00 +00:00
merge translations (based part)
This commit is contained in:
parent
5145afb625
commit
6f7c0c2de3
3 changed files with 1031 additions and 769 deletions
|
@ -3,6 +3,7 @@ import { fileURLToPath } from 'node:url';
|
|||
import { dirname } from 'node:path';
|
||||
import * as yaml from 'js-yaml';
|
||||
import ts from 'typescript';
|
||||
import { merge } from './index.js';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
@ -56,7 +57,10 @@ function createMembers(record) {
|
|||
}
|
||||
|
||||
export default function generateDTS() {
|
||||
const locale = yaml.load(fs.readFileSync(`${__dirname}/ja-JP.yml`, 'utf-8'));
|
||||
const sharkeyLocale = yaml.load(fs.readFileSync(`${__dirname}/../sharkey-locales/ja-JP.yml`, 'utf-8'));
|
||||
const misskeyLocale = yaml.load(fs.readFileSync(`${__dirname}/ja-JP.yml`, 'utf-8'));
|
||||
const locale = merge(misskeyLocale, sharkeyLocale);
|
||||
|
||||
const members = createMembers(locale);
|
||||
const elements = [
|
||||
ts.factory.createVariableStatement(
|
||||
|
|
1787
locales/index.d.ts
vendored
1787
locales/index.d.ts
vendored
File diff suppressed because it is too large
Load diff
|
@ -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) => {
|
||||
|
|
Loading…
Reference in a new issue