Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Extract translation languages to shared module

Richie McIlroya7f62b3c2b93
diff --git a/apps/web/actions/videos/get-available-translations.ts b/apps/web/actions/videos/get-available-translations.ts
index 82ca2eddd..db9784018 100644
--- a/apps/web/actions/videos/get-available-translations.ts
+++ b/apps/web/actions/videos/get-available-translations.ts
@@ -7,7 +7,10 @@ import type { Video } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { Effect, Option } from "effect";
import { runPromise } from "@/lib/server";
-import { type LanguageCode, SUPPORTED_LANGUAGES } from "./translate-transcript";
+import {
+ type LanguageCode,
+ SUPPORTED_LANGUAGES,
+} from "./translation-languages";
interface AvailableTranslation {
code: LanguageCode;
diff --git a/apps/web/actions/videos/translate-transcript.ts b/apps/web/actions/videos/translate-transcript.ts
index 25b730a00..c52b4e53d 100644
--- a/apps/web/actions/videos/translate-transcript.ts
+++ b/apps/web/actions/videos/translate-transcript.ts
@@ -8,25 +8,10 @@ import { eq } from "drizzle-orm";
import { Effect, Option } from "effect";
import { GROQ_MODEL, getGroqClient } from "@/lib/groq-client";
import { runPromise } from "@/lib/server";
-
-export const SUPPORTED_LANGUAGES = {
- en: "English",
- es: "Spanish",
- fr: "French",
- de: "German",
- pt: "Portuguese",
- it: "Italian",
- nl: "Dutch",
- pl: "Polish",
- ru: "Russian",
- ja: "Japanese",
- ko: "Korean",
- zh: "Chinese (Simplified)",
- ar: "Arabic",
- hi: "Hindi",
-} as const;
-
-export type LanguageCode = keyof typeof SUPPORTED_LANGUAGES;
+import {
+ type LanguageCode,
+ SUPPORTED_LANGUAGES,
+} from "./translation-languages";
interface TranslateResult {
success: boolean;
diff --git a/apps/web/actions/videos/translation-languages.ts b/apps/web/actions/videos/translation-languages.ts
new file mode 100644
index 000000000..fe8f0e694
--- /dev/null
+++ b/apps/web/actions/videos/translation-languages.ts
@@ -0,0 +1,18 @@
+export const SUPPORTED_LANGUAGES = {
+ en: "English",
+ es: "Spanish",
+ fr: "French",
+ de: "German",
+ pt: "Portuguese",
+ it: "Italian",
+ nl: "Dutch",
+ pl: "Polish",
+ ru: "Russian",
+ ja: "Japanese",
+ ko: "Korean",
+ zh: "Chinese (Simplified)",
+ ar: "Arabic",
+ hi: "Hindi",
+} as const;
+
+export type LanguageCode = keyof typeof SUPPORTED_LANGUAGES;
diff --git a/apps/web/app/s/[videoId]/_components/CaptionContext.tsx b/apps/web/app/s/[videoId]/_components/CaptionContext.tsx
index 3300327ce..69b811265 100644
--- a/apps/web/app/s/[videoId]/_components/CaptionContext.tsx
+++ b/apps/web/app/s/[videoId]/_components/CaptionContext.tsx
@@ -11,11 +11,11 @@ import {
useState,
} from "react";
import { getAvailableTranslations } from "@/actions/videos/get-available-translations";
+import { translateTranscript } from "@/actions/videos/translate-transcript";
import {
type LanguageCode,
SUPPORTED_LANGUAGES,
- translateTranscript,
-} from "@/actions/videos/translate-transcript";
+} from "@/actions/videos/translation-languages";
export type CaptionLanguage = LanguageCode | "original" | "off";
diff --git a/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx b/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx
index 2ccee0f30..772f0ffd2 100644
--- a/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx
+++ b/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx
@@ -18,7 +18,7 @@ import { editTranscriptEntry } from "@/actions/videos/edit-transcript";
import {
type LanguageCode,
SUPPORTED_LANGUAGES,
-} from "@/actions/videos/translate-transcript";
+} from "@/actions/videos/translation-languages";
import { useCurrentUser } from "@/app/Layout/AuthContext";
import type { VideoData } from "../../types";
import { type CaptionLanguage, useCaptionContext } from "../CaptionContext";