mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
import { writeFileSync } from 'node:fs';
|
|
import { resolve } from 'node:path';
|
|
|
|
import { LOCALES, localeAliases } from '@videojs/core/i18n';
|
|
|
|
const outPath = resolve(import.meta.dirname, '../app/shared/i18n/cdn-locale-loaders.generated.ts');
|
|
|
|
function localeObjectKey(tag: string): string {
|
|
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(tag) ? tag : `'${tag}'`;
|
|
}
|
|
|
|
const localePacks = [...LOCALES, ...localeAliases(LOCALES)];
|
|
|
|
const entries = localePacks
|
|
.sort((a, b) => a.localeCompare(b, 'en'))
|
|
.map((tag) => ` ${localeObjectKey(tag)}: () => import('@videojs/html/cdn/locales/${tag}'),`)
|
|
.join('\n');
|
|
|
|
const source = `/** Generated by scripts/generate-cdn-locale-loaders.ts — do not edit. */
|
|
import type { SandboxLocalePack } from './locale-meta';
|
|
|
|
/** CDN locale chunks register via \`../i18n.dev.js\` — same module graph as \`@videojs/html/cdn/video\`. */
|
|
export const cdnLocaleLoaders = {
|
|
${entries}
|
|
} as const satisfies Record<Exclude<SandboxLocalePack, 'en'>, () => Promise<unknown>>;
|
|
`;
|
|
|
|
writeFileSync(outPath, source);
|