Skip to content

Build your personal knowledge base with Trilium Notes

ci(i18n): run the coverage check only on Weblate's pull requests

Elian Doran7f6dcd9d8fa8
diff --git a/.github/workflows/i18n.yml b/.github/workflows/i18n.yml
index 6689b6e7a1..73a0f62d0e 100644
--- a/.github/workflows/i18n.yml
+++ b/.github/workflows/i18n.yml
@@ -1,17 +1,6 @@
name: Internationalization
on:
- push:
- branches:
- - "weblate:*"
- workflow_dispatch:
pull_request:
- paths:
- - "apps/client/src/translations/**"
- - "apps/website/src/translations/**"
- - "apps/website/src/locales.ts"
- - "packages/commons/src/lib/i18n.ts"
- - "scripts/translation/**"
- - ".github/workflows/i18n.yml"
permissions:
contents: read
@@ -19,18 +8,14 @@ permissions:
jobs:
i18n-check:
name: Check i18n translations
+ if: github.event.pull_request.user.login == 'weblate'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- - name: Set up node & dependencies
- uses: actions/setup-node@v7
+ - uses: actions/setup-node@v7
with:
node-version: 24
- cache: 'pnpm'
- - name: Install dependencies
- run: pnpm install --frozen-lockfile
- name: Check translations
- run: pnpm tsx scripts/translation/check-translation-coverage.ts
+ run: node scripts/translation/check-translation-coverage.mts
diff --git a/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translations/Adding a new locale.md b/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translations/Adding a new locale.md
index c895702083..b303757f12 100644
--- a/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translations/Adding a new locale.md
+++ b/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translations/Adding a new locale.md
@@ -22,6 +22,6 @@ The website tracks its own Weblate component and its own list, so a locale added
## The coverage gate
-`scripts/translation/check-translation-coverage.ts` fails CI once Weblate reports a language above 50% that is missing from either list. It runs on the `weblate:*` branches, so the pull request that brings the translations in is where it fires.
+`scripts/translation/check-translation-coverage.mts` fails CI once Weblate reports a language above 50% that is missing from either list. It runs only on the pull requests Weblate opens, so the pull request that brings the translations in is where it fires.
The gate only catches a language that is translated but not offered. It does not notice one that is offered and has since fallen behind, and it does not check that the locale renders — only that the id is listed.
\ No newline at end of file
diff --git a/scripts/translation/check-translation-coverage.ts b/scripts/translation/check-translation-coverage.mts
similarity index 95%
rename from scripts/translation/check-translation-coverage.ts
rename to scripts/translation/check-translation-coverage.mts
index ff2d7e588b..d448059349 100644
--- a/scripts/translation/check-translation-coverage.ts
+++ b/scripts/translation/check-translation-coverage.mts
@@ -1,6 +1,6 @@
-import { LOCALES as WEBSITE_LOCALES } from "../../apps/website/src/locales";
-import { LOCALES as APP_LOCALES } from "../../packages/commons/src/lib/i18n";
-import { getLanguageStats, type WeblateProject } from "./utils";
+import { LOCALES as WEBSITE_LOCALES } from "../../apps/website/src/locales.ts";
+import { LOCALES as APP_LOCALES } from "../../packages/commons/src/lib/i18n.ts";
+import { getLanguageStats, type WeblateProject } from "./utils.mts";
/**
* Coverage above which a language must be offered, rather than sitting
diff --git a/scripts/translation/manage-readme.ts b/scripts/translation/manage-readme.ts
index ba406f835e..2e05821125 100644
--- a/scripts/translation/manage-readme.ts
+++ b/scripts/translation/manage-readme.ts
@@ -1,7 +1,7 @@
import { readFile, writeFile } from "fs/promises";
import { join } from "path";
-import { getLanguageStats } from "./utils";
+import { getLanguageStats } from "./utils.mts";
const scriptDir = __dirname;
const rootDir = join(scriptDir, "../..");
diff --git a/scripts/translation/utils.ts b/scripts/translation/utils.mts
similarity index 98%
rename from scripts/translation/utils.ts
rename to scripts/translation/utils.mts
index fb19f84fc1..7635c94f85 100644
--- a/scripts/translation/utils.ts
+++ b/scripts/translation/utils.mts
@@ -1,7 +1,7 @@
import { readFile, stat,writeFile } from "fs/promises";
import { join } from "path";
-const scriptDir = __dirname;
+const scriptDir = import.meta.dirname;
/** The Weblate components under https://hosted.weblate.org/projects/trilium/ that are gated. */
export type WeblateProject = "readme" | "client" | "website";
diff --git a/scripts/translation/utils.spec.ts b/scripts/translation/utils.spec.ts
index a1825a065e..41c91c6cdf 100644
--- a/scripts/translation/utils.spec.ts
+++ b/scripts/translation/utils.spec.ts
@@ -1,6 +1,6 @@
import { afterEach, describe, expect, it, vi } from "vitest";
-import { CACHE_MAX_AGE_MS, fetchAllPages, isCacheFresh } from "./utils";
+import { CACHE_MAX_AGE_MS, fetchAllPages, isCacheFresh } from "./utils.mts";
describe("isCacheFresh", () => {
const now = new Date("2026-08-20T12:00:00Z").getTime();
diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json
index 5430998b69..03823588d6 100644
--- a/scripts/tsconfig.json
+++ b/scripts/tsconfig.json
@@ -4,6 +4,7 @@
"module": "ESNext",
"moduleResolution": "bundler",
"target": "es2023",
+ "rewriteRelativeImportExtensions": true,
"outDir": "dist",
"rootDir": "..",
"types": [