Skip to content

Commit c106740

Browse files
fix: skip lingo.dev i18n automation when API key is not set (calcom#28704)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 9b3bbb9 commit c106740

2 files changed

Lines changed: 26 additions & 9 deletions

File tree

.github/workflows/i18n.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ concurrency:
1010
jobs:
1111
i18n:
1212
name: Run i18n
13+
if: ${{ secrets.CI_LINGO_DOT_DEV_API_KEY != '' }}
1314
runs-on: blacksmith-2vcpu-ubuntu-2404
1415
permissions:
1516
actions: write

packages/lib/server/service/lingoDotDev.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import type { LocaleCode } from "@lingo.dev/_spec";
2-
import { LingoDotDevEngine } from "lingo.dev/sdk";
3-
41
import { LINGO_DOT_DEV_API_KEY } from "@calcom/lib/constants";
52
import logger from "@calcom/lib/logger";
3+
import type { LocaleCode } from "@lingo.dev/_spec";
4+
import { LingoDotDevEngine } from "lingo.dev/sdk";
65

76
export class LingoDotDevService {
8-
private static engine = new LingoDotDevEngine({
9-
apiKey: LINGO_DOT_DEV_API_KEY,
10-
});
7+
private static engine = LINGO_DOT_DEV_API_KEY
8+
? new LingoDotDevEngine({
9+
apiKey: LINGO_DOT_DEV_API_KEY,
10+
})
11+
: null;
1112

1213
/**
1314
* Localizes text from one language to another
@@ -25,8 +26,13 @@ export class LingoDotDevService {
2526
return null;
2627
}
2728

29+
if (!LingoDotDevService.engine) {
30+
logger.warn("LingoDotDevService.localizeText() skipped: LINGO_DOT_DEV_API_KEY is not set");
31+
return null;
32+
}
33+
2834
try {
29-
const result = await this.engine.localizeText(text, {
35+
const result = await LingoDotDevService.engine.localizeText(text, {
3036
sourceLocale,
3137
targetLocale,
3238
});
@@ -50,8 +56,13 @@ export class LingoDotDevService {
5056
sourceLocale: string,
5157
targetLocales: string[]
5258
): Promise<string[]> {
59+
if (!LingoDotDevService.engine) {
60+
logger.warn("LingoDotDevService.batchLocalizeText() skipped: LINGO_DOT_DEV_API_KEY is not set");
61+
return [];
62+
}
63+
5364
try {
54-
const result = await this.engine.batchLocalizeText(text, {
65+
const result = await LingoDotDevService.engine.batchLocalizeText(text, {
5566
// TODO: LocaleCode is hacky, use our locale mapping instead.
5667
sourceLocale: sourceLocale as LocaleCode,
5768
targetLocales: targetLocales as LocaleCode[],
@@ -76,8 +87,13 @@ export class LingoDotDevService {
7687
return texts;
7788
}
7889

90+
if (!LingoDotDevService.engine) {
91+
logger.warn("LingoDotDevService.localizeTexts() skipped: LINGO_DOT_DEV_API_KEY is not set");
92+
return texts;
93+
}
94+
7995
try {
80-
const result = await this.engine.localizeChat(
96+
const result = await LingoDotDevService.engine.localizeChat(
8197
texts.map((text) => ({ name: "NO_NAME", text: text.trim() })),
8298
{
8399
sourceLocale,

0 commit comments

Comments
 (0)