Scheduling infrastructure for absolutely everyone.
fix: skip lingo.dev i18n automation when API key is not set (#28704)
Keith Williamsc106740d17e6
diff --git a/.github/workflows/i18n.yml b/.github/workflows/i18n.ymlindex 28152562c77..592cf462d91 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-2404permissions:actions: writediff --git a/packages/lib/server/service/lingoDotDev.ts b/packages/lib/server/service/lingoDotDev.tsindex d64bc5bb891..5cac5a798aa 100644--- a/packages/lib/server/service/lingoDotDev.ts+++ b/packages/lib/server/service/lingoDotDev.ts@@ -1,13 +1,14 @@-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";+import type { LocaleCode } from "@lingo.dev/_spec";+import { LingoDotDevEngine } from "lingo.dev/sdk";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<string[]> {+ 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,