mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-20 00:18:45 +01:00
Replace typescript compiler with native tsgo compiler
This commit is contained in:
@@ -5,7 +5,6 @@ import { join } from 'node:path';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import lodash from 'lodash';
|
||||
import * as LocaleMatcher from '@formatjs/intl-localematcher';
|
||||
import { z } from 'zod';
|
||||
import { setupI18n } from '../ts/util/setupI18nMain.std.js';
|
||||
import { shouldNeverBeCalled } from '../ts/util/shouldNeverBeCalled.std.js';
|
||||
|
||||
@@ -15,18 +14,12 @@ import type {
|
||||
LocaleMessagesType,
|
||||
} from '../ts/types/I18N.std.js';
|
||||
import type { LocalizerType } from '../ts/types/Util.std.js';
|
||||
import * as Errors from '../ts/types/errors.std.js';
|
||||
import { parseUnknown } from '../ts/util/schemas.std.js';
|
||||
|
||||
const { merge } = lodash;
|
||||
|
||||
type CompactLocaleMessagesType = ReadonlyArray<string | null>;
|
||||
type CompactLocaleKeysType = ReadonlyArray<string>;
|
||||
|
||||
const TextInfoSchema = z.object({
|
||||
direction: z.enum(['ltr', 'rtl']),
|
||||
});
|
||||
|
||||
function getLocaleMessages(locale: string): LocaleMessagesType {
|
||||
const targetFile = join(__dirname, '..', '_locales', locale, 'messages.json');
|
||||
|
||||
@@ -80,37 +73,8 @@ export type LocaleType = {
|
||||
countryDisplayNames: CountryDisplayNames;
|
||||
};
|
||||
|
||||
function getLocaleDirection(
|
||||
localeName: string,
|
||||
logger: LoggerType
|
||||
): LocaleDirection {
|
||||
const locale = new Intl.Locale(localeName);
|
||||
// TC39 proposal is now `locale.getTextInfo()` but in browsers its currently
|
||||
// `locale.textInfo`
|
||||
try {
|
||||
// @ts-expect-error -- TS doesn't know about this method
|
||||
if (typeof locale.getTextInfo === 'function') {
|
||||
return parseUnknown(
|
||||
TextInfoSchema,
|
||||
// @ts-expect-error -- TS doesn't know about this method
|
||||
locale.getTextInfo() as unknown
|
||||
).direction;
|
||||
}
|
||||
// @ts-expect-error -- TS doesn't know about this property
|
||||
if (typeof locale.textInfo === 'object') {
|
||||
return parseUnknown(
|
||||
TextInfoSchema,
|
||||
// @ts-expect-error -- TS doesn't know about this property
|
||||
locale.textInfo as unknown
|
||||
).direction;
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
'locale: Error getting text info for locale',
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
}
|
||||
return 'ltr';
|
||||
function getLocaleDirection(localeName: string): LocaleDirection {
|
||||
return new Intl.Locale(localeName).getTextInfo().direction ?? 'ltr';
|
||||
}
|
||||
|
||||
export function _getAvailableLocales(): Array<string> {
|
||||
@@ -202,7 +166,7 @@ export function load({
|
||||
getHourCyclePreference: shouldNeverBeCalled,
|
||||
});
|
||||
const direction =
|
||||
localeDirectionTestingOverride ?? getLocaleDirection(matchedLocale, logger);
|
||||
localeDirectionTestingOverride ?? getLocaleDirection(matchedLocale);
|
||||
logger.info(`locale: Text info direction for ${matchedLocale}: ${direction}`);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user