kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
translationRunner: hack around lack of ESM support
rodzic
e3fc812204
commit
97dab66203
|
@ -1,9 +1,14 @@
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
import * as parser from 'intl-messageformat-parser';
|
import * as parser from 'intl-messageformat-parser';
|
||||||
import manageTranslations, { readMessageFiles, ExtractedDescriptor } from 'react-intl-translations-manager';
|
import manager from 'react-intl-translations-manager';
|
||||||
import yargs from 'yargs';
|
import yargs from 'yargs/yargs';
|
||||||
|
|
||||||
|
import type { ExtractedDescriptor } from 'react-intl-translations-manager';
|
||||||
|
|
||||||
|
const { default: manageTranslations, readMessageFiles } = manager as unknown as typeof import('react-intl-translations-manager');
|
||||||
|
|
||||||
type Validator = (language: string) => void;
|
type Validator = (language: string) => void;
|
||||||
|
|
||||||
|
@ -14,6 +19,7 @@ interface LanguageResult {
|
||||||
|
|
||||||
const RFC5646_REGEXP = /^[a-z]{2,3}(?:-(?:x|[A-Za-z]{2,4}))*$/;
|
const RFC5646_REGEXP = /^[a-z]{2,3}(?:-(?:x|[A-Za-z]{2,4}))*$/;
|
||||||
|
|
||||||
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
const rootDirectory = path.resolve(__dirname, '..');
|
const rootDirectory = path.resolve(__dirname, '..');
|
||||||
const translationsDirectory = path.resolve(rootDirectory, 'src', 'locales');
|
const translationsDirectory = path.resolve(rootDirectory, 'src', 'locales');
|
||||||
const messagesDirectory = path.resolve(rootDirectory, 'build', 'messages');
|
const messagesDirectory = path.resolve(rootDirectory, 'build', 'messages');
|
||||||
|
@ -69,7 +75,7 @@ Available languages:
|
||||||
${availableLanguages.join(', ')}
|
${availableLanguages.join(', ')}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const argv = yargs
|
const argv = yargs()
|
||||||
.usage(usage)
|
.usage(usage)
|
||||||
.option('f', {
|
.option('f', {
|
||||||
alias: 'force',
|
alias: 'force',
|
||||||
|
|
Ładowanie…
Reference in New Issue