diff --git a/.github/workflows/i18n.yml b/.github/workflows/i18n.yml index 28152562c7..592cf462d9 100644 --- a/.github/workflows/i18n.yml +++ b/.github/workflows/i18n.yml @@ -10,6 +10,7 @@ concurrency: jobs: i18n: name: Run i18n + if: ${{ secrets.CI_LINGO_DOT_DEV_API_KEY != '' }} runs-on: blacksmith-2vcpu-ubuntu-2404 permissions: actions: write diff --git a/packages/lib/server/service/lingoDotDev.ts b/packages/lib/server/service/lingoDotDev.ts index d64bc5bb89..5cac5a798a 100644 --- a/packages/lib/server/service/lingoDotDev.ts +++ b/packages/lib/server/service/lingoDotDev.ts @@ -1,13 +1,14 @@ +import { LINGO_DOT_DEV_API_KEY } from "@calcom/lib/constants"; +import logger from "@calcom/lib/logger"; import type { LocaleCode } from "@lingo.dev/_spec"; import { LingoDotDevEngine } from "lingo.dev/sdk"; -import { LINGO_DOT_DEV_API_KEY } from "@calcom/lib/constants"; -import logger from "@calcom/lib/logger"; - export class LingoDotDevService { - private static engine = new LingoDotDevEngine({ - apiKey: LINGO_DOT_DEV_API_KEY, - }); + private static engine = LINGO_DOT_DEV_API_KEY + ? new LingoDotDevEngine({ + apiKey: LINGO_DOT_DEV_API_KEY, + }) + : null; /** * Localizes text from one language to another @@ -25,8 +26,13 @@ export class LingoDotDevService { return null; } + if (!LingoDotDevService.engine) { + logger.warn("LingoDotDevService.localizeText() skipped: LINGO_DOT_DEV_API_KEY is not set"); + return null; + } + try { - const result = await this.engine.localizeText(text, { + const result = await LingoDotDevService.engine.localizeText(text, { sourceLocale, targetLocale, }); @@ -50,8 +56,13 @@ export class LingoDotDevService { sourceLocale: string, targetLocales: string[] ): Promise { + if (!LingoDotDevService.engine) { + logger.warn("LingoDotDevService.batchLocalizeText() skipped: LINGO_DOT_DEV_API_KEY is not set"); + return []; + } + try { - const result = await this.engine.batchLocalizeText(text, { + const result = await LingoDotDevService.engine.batchLocalizeText(text, { // TODO: LocaleCode is hacky, use our locale mapping instead. sourceLocale: sourceLocale as LocaleCode, targetLocales: targetLocales as LocaleCode[], @@ -76,8 +87,13 @@ export class LingoDotDevService { return texts; } + if (!LingoDotDevService.engine) { + logger.warn("LingoDotDevService.localizeTexts() skipped: LINGO_DOT_DEV_API_KEY is not set"); + return texts; + } + try { - const result = await this.engine.localizeChat( + const result = await LingoDotDevService.engine.localizeChat( texts.map((text) => ({ name: "NO_NAME", text: text.trim() })), { sourceLocale,