mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-28 15:31:11 -04:00
initial prep
This commit is contained in:
parent
005c2b04ca
commit
c0e86d6111
0
i18n/configs/.gitkeep
Normal file
0
i18n/configs/.gitkeep
Normal file
96
i18n/defs.ts
Normal file
96
i18n/defs.ts
Normal file
@ -0,0 +1,96 @@
|
||||
import assert from 'node:assert';
|
||||
import fs from 'node:fs';
|
||||
|
||||
import type { LocaleObject, Directions } from '@nuxtjs/i18n';
|
||||
import YAML from 'yaml';
|
||||
|
||||
interface LocaleCodeMap<C extends string = string> {
|
||||
iso639_3: C;
|
||||
wals?: string;
|
||||
itef?: string;
|
||||
}
|
||||
|
||||
interface LocaleMisc {
|
||||
dir?: Directions;
|
||||
nativeName?: string;
|
||||
region?: string;
|
||||
script?: string;
|
||||
variant?: string;
|
||||
}
|
||||
|
||||
export interface LocaleInit<C extends string = string> {
|
||||
code: LocaleCodeMap<C>;
|
||||
name: string;
|
||||
nameEnglish: string;
|
||||
url: string;
|
||||
published: boolean;
|
||||
symbol: string;
|
||||
family: string;
|
||||
extra?: string | null;
|
||||
misc?: LocaleMisc;
|
||||
}
|
||||
|
||||
export interface LocaleInterface<C extends string = string> extends LocaleInit<C> {
|
||||
fullName: string;
|
||||
i18nLocale: LocaleObject<C>;
|
||||
config: Record<string, unknown>;
|
||||
matches(filter: string): boolean;
|
||||
}
|
||||
|
||||
export class Locale<C extends string = string> implements LocaleInterface<C> {
|
||||
code: LocaleCodeMap<C>;
|
||||
name: string;
|
||||
nameEnglish: string;
|
||||
url: string;
|
||||
published: boolean;
|
||||
symbol: string;
|
||||
family: string;
|
||||
extra: string | null = null;
|
||||
misc?: LocaleMisc;
|
||||
constructor(init: LocaleInit<C>) {
|
||||
this.code = init.code;
|
||||
this.name = init.name;
|
||||
this.nameEnglish = init.nameEnglish;
|
||||
this.url = init.url;
|
||||
this.published = init.published;
|
||||
this.symbol = init.symbol;
|
||||
this.family = init.family;
|
||||
this.extra = init.extra ?? null;
|
||||
this.misc = init.misc;
|
||||
}
|
||||
|
||||
get fullName(): string {
|
||||
return this.extra ? `${this.name} (${this.extra})` : this.name;
|
||||
}
|
||||
|
||||
get i18nLocale() {
|
||||
return {
|
||||
code: this.code.iso639_3,
|
||||
name: this.nameEnglish,
|
||||
file: `${this.code.iso639_3}.yaml`,
|
||||
dir: this.misc?.dir ?? 'ltr',
|
||||
language: this.code.itef ?? this.code.iso639_3,
|
||||
domain: this.url.replace(/^https?:\/\//, ''),
|
||||
} as LocaleObject<C>;
|
||||
}
|
||||
|
||||
get config(): Record<string, unknown> {
|
||||
const configPath = `./configs/${this.code.iso639_3}.yaml`;
|
||||
assert(fs.existsSync(configPath));
|
||||
const file = fs.readFileSync(configPath, 'utf8');
|
||||
return YAML.parse(file) as Record<string, unknown>;
|
||||
}
|
||||
|
||||
matches(filter: string): boolean {
|
||||
const filterNormalised = filter.toLocaleLowerCase();
|
||||
|
||||
return [
|
||||
this.name,
|
||||
this.nameEnglish,
|
||||
this.extra ?? '',
|
||||
this.code.iso639_3,
|
||||
this.code.wals ?? '',
|
||||
this.code.itef ?? '',
|
||||
].some((value) => value.toLocaleLowerCase().includes(filterNormalised));
|
||||
}
|
||||
}
|
40
i18n/locales.ts
Normal file
40
i18n/locales.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { Locale } from './defs.ts';
|
||||
|
||||
export default [
|
||||
new Locale({
|
||||
code: { iso639_3: '_' },
|
||||
name: 'Base',
|
||||
nameEnglish: 'Base',
|
||||
url: 'https://pronouns.page',
|
||||
published: false,
|
||||
symbol: '_',
|
||||
family: 'germanic',
|
||||
}),
|
||||
new Locale({
|
||||
code: { iso639_3: 'de', wals: 'ger' },
|
||||
name: 'Deutsch',
|
||||
nameEnglish: 'German',
|
||||
url: 'https://pronomen.net',
|
||||
published: true,
|
||||
symbol: 'ß',
|
||||
family: 'germanic',
|
||||
}),
|
||||
new Locale({
|
||||
code: { iso639_3: 'es', wals: 'spa' },
|
||||
name: 'Español',
|
||||
nameEnglish: 'Spanish',
|
||||
url: 'https://pronombr.es',
|
||||
published: true,
|
||||
symbol: 'ñ',
|
||||
family: 'romance',
|
||||
}),
|
||||
new Locale({
|
||||
code: { iso639_3: 'eo' },
|
||||
name: 'Esperanto',
|
||||
nameEnglish: 'Esperanto',
|
||||
url: 'https://pronomejo.net',
|
||||
published: true,
|
||||
symbol: 'ĥ',
|
||||
family: 'constructed',
|
||||
}),
|
||||
];
|
0
i18n/locales/.gitkeep
Normal file
0
i18n/locales/.gitkeep
Normal file
@ -1,5 +1,5 @@
|
||||
import childProcess from 'node:child_process';
|
||||
import { promisify } from 'node:util';
|
||||
import assert from 'node:assert';
|
||||
import { readFileSync, existsSync } from 'node:fs';
|
||||
import path from 'path';
|
||||
|
||||
import { resolvePath } from '@nuxt/kit';
|
||||
@ -7,6 +7,7 @@ import yamlPlugin from '@rollup/plugin-yaml';
|
||||
import { sentryVitePlugin } from '@sentry/vite-plugin';
|
||||
import { defineNuxtConfig } from 'nuxt/config';
|
||||
|
||||
import Locales from './i18n/locales.ts';
|
||||
import type { Config } from './locale/config.ts';
|
||||
import localeDescriptions from './locale/locales.ts';
|
||||
import type { Translations } from './locale/translations.ts';
|
||||
@ -15,8 +16,12 @@ import sumlPlugin from './plugins/rollup/suml.ts';
|
||||
import tsvPlugin from './plugins/rollup/tsv.ts';
|
||||
import { loadSuml } from './server/loader.ts';
|
||||
|
||||
const exec = promisify(childProcess.exec);
|
||||
const version = (await exec('git log -n 1 --pretty=format:"%H"')).stdout;
|
||||
function getVersion() {
|
||||
assert(existsSync('.git'), '.git does not exist, cannot get version');
|
||||
return readFileSync('.git/logs/HEAD', 'utf-8').trim().split(' ')[0].substring(8);
|
||||
}
|
||||
|
||||
const version = getVersion();
|
||||
|
||||
const config = await loadSuml<Config>('locale/_/config.suml');
|
||||
const translations = await loadSuml<Translations>('locale/_/translations.suml');
|
||||
@ -56,7 +61,11 @@ export default defineNuxtConfig({
|
||||
'@vite-pwa/nuxt',
|
||||
'@nuxt/test-utils/module',
|
||||
'@nuxt/eslint',
|
||||
'@nuxtjs/i18n',
|
||||
],
|
||||
imports: {
|
||||
autoImport: true,
|
||||
},
|
||||
devtools: {
|
||||
enabled: true,
|
||||
},
|
||||
@ -271,6 +280,9 @@ export default defineNuxtConfig({
|
||||
},
|
||||
},
|
||||
},
|
||||
i18n: {
|
||||
locales: Locales.map((locale) => locale.i18nLocale),
|
||||
},
|
||||
pwa: {
|
||||
registerType: 'autoUpdate',
|
||||
manifest: {
|
||||
|
@ -25,6 +25,7 @@
|
||||
"@aws-sdk/client-s3": "^3.525.0",
|
||||
"@floating-ui/vue": "^1.1.5",
|
||||
"@fortawesome/fontawesome-pro": "https://gitlab.com/Avris/FontAwesomePro",
|
||||
"@nuxtjs/i18n": "^10.0.6",
|
||||
"@sentry/browser": "^7.109.0",
|
||||
"@sentry/cli": "^2.31.0",
|
||||
"@sentry/node": "^7.109.0",
|
||||
@ -41,6 +42,7 @@
|
||||
"jose": "^5.9.6",
|
||||
"js-base64": "^3.5.2",
|
||||
"jsdom": "^26.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"luxon": "^1.28.1",
|
||||
"mastodon": "^1.2.2",
|
||||
"minisearch": "^7.1.1",
|
||||
|
656
pnpm-lock.yaml
generated
656
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user