diff --git a/deno.json b/deno.json index 80c58382..db38e978 100644 --- a/deno.json +++ b/deno.json @@ -72,7 +72,7 @@ "fast-stable-stringify": "npm:fast-stable-stringify@^1.0.0", "formdata-helper": "npm:formdata-helper@^0.3.0", "hono-rate-limiter": "npm:hono-rate-limiter@^0.3.0", - "iso-639-1": "npm:iso-639-1@2.1.15", + "iso-639-1": "npm:iso-639-1@^3.1.5", "isomorphic-dompurify": "npm:isomorphic-dompurify@^2.16.0", "kysely": "npm:kysely@^0.27.4", "kysely-postgres-js": "npm:kysely-postgres-js@2.0.0", diff --git a/deno.lock b/deno.lock index 5e4134da..32e9a8bb 100644 --- a/deno.lock +++ b/deno.lock @@ -101,7 +101,7 @@ "npm:fast-stable-stringify@1": "1.0.0", "npm:formdata-helper@0.3": "0.3.0", "npm:hono-rate-limiter@0.3": "0.3.0_hono@4.2.5", - "npm:iso-639-1@2.1.15": "2.1.15", + "npm:iso-639-1@^3.1.5": "3.1.5", "npm:isomorphic-dompurify@^2.16.0": "2.16.0", "npm:kysely-postgres-js@2.0.0": "2.0.0_kysely@0.27.3_postgres@3.4.4", "npm:kysely@~0.27.2": "0.27.4", @@ -1211,8 +1211,8 @@ "isexe@2.0.0": { "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" }, - "iso-639-1@2.1.15": { - "integrity": "sha512-7c7mBznZu2ktfvyT582E2msM+Udc1EjOyhVRE/0ZsjD9LBtWSm23h3PtiRh2a35XoUsTQQjJXaJzuLjXsOdFDg==" + "iso-639-1@3.1.5": { + "integrity": "sha512-gXkz5+KN7HrG0Q5UGqSMO2qB9AsbEeyLP54kF1YrMsIxmu+g4BdB7rflReZTSTZGpfj8wywu6pfPBCylPIzGQA==" }, "isomorphic-dompurify@2.16.0": { "integrity": "sha512-cXhX2owp8rPxafCr0ywqy2CGI/4ceLNgWkWBEvUz64KTbtg3oRL2ZRqq/zW0pzt4YtDjkHLbwcp/lozpKzAQjg==", @@ -2383,7 +2383,7 @@ "npm:fast-stable-stringify@1", "npm:formdata-helper@0.3", "npm:hono-rate-limiter@0.3", - "npm:iso-639-1@2.1.15", + "npm:iso-639-1@^3.1.5", "npm:isomorphic-dompurify@^2.16.0", "npm:kysely-postgres-js@2.0.0", "npm:kysely@~0.27.4", diff --git a/src/config.ts b/src/config.ts index b65e0cfd..0164182a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -293,7 +293,7 @@ class Conf { } /** Languages this server wishes to highlight. Used when querying trends.*/ static get preferredLanguages(): LanguageCode[] | undefined { - return Deno.env.get('DITTO_LANGUAGES')?.split(',')?.filter(ISO6391.validate) as LanguageCode[]; + return Deno.env.get('DITTO_LANGUAGES')?.split(',')?.filter(ISO6391.validate); } /** Translation provider used to translate posts. */ static get translationProvider(): string | undefined { diff --git a/src/schema.ts b/src/schema.ts index b55a1f9a..0fce60d4 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -60,7 +60,7 @@ const languageSchema = z.string().transform((val, ctx) => { }); return z.NEVER; } - return val as LanguageCode; + return val; }); const localeSchema = z.string().transform((val, ctx) => { diff --git a/src/test.ts b/src/test.ts index 4e813f05..95aa2872 100644 --- a/src/test.ts +++ b/src/test.ts @@ -75,7 +75,7 @@ export function getLanguage(text: string): LanguageCode | undefined { const [iso6393] = topResult; const locale = new Intl.Locale(iso6393); if (ISO6391.validate(locale.language)) { - return locale.language as LanguageCode; + return locale.language; } } return; diff --git a/src/translators/DeepLTranslator.ts b/src/translators/DeepLTranslator.ts index 26067379..d1cefaaa 100644 --- a/src/translators/DeepLTranslator.ts +++ b/src/translators/DeepLTranslator.ts @@ -36,7 +36,7 @@ export class DeepLTranslator implements DittoTranslator { return { results: translations.map((value) => value.text), - source_lang: translations[0]?.detected_source_language as LanguageCode, + source_lang: translations[0]?.detected_source_language, }; } diff --git a/src/utils/language.ts b/src/utils/language.ts index 4b6e3807..b95e3e78 100644 --- a/src/utils/language.ts +++ b/src/utils/language.ts @@ -46,7 +46,7 @@ export function detectLanguage(text: string, minConfidence: number): LanguageCod const locale = new Intl.Locale(iso6393); if (confidence >= minConfidence && ISO6391.validate(locale.language)) { - return locale.language as LanguageCode; + return locale.language; } } }