mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-09-15 05:02:13 +02:00
Change default language to en-US and add US language (#6621)
This commit is contained in:
@@ -154,8 +154,8 @@ export async function mockAppApis(
|
||||
email: "[email protected]",
|
||||
roles: ["ROLE_USER"],
|
||||
},
|
||||
languages = ["en-GB"],
|
||||
defaultLocale = "en-GB",
|
||||
languages = ["en-US"],
|
||||
defaultLocale = "en-US",
|
||||
endpointsAvailability = {},
|
||||
backendStatus = "UP",
|
||||
} = opts;
|
||||
|
||||
@@ -6,9 +6,9 @@ import { parse } from "smol-toml";
|
||||
|
||||
const REPO_ROOT = path.join(__dirname, "../../../..");
|
||||
const SRC_ROOT = path.join(__dirname, "../..");
|
||||
const EN_GB_FILE = path.join(
|
||||
const EN_US_FILE = path.join(
|
||||
__dirname,
|
||||
"../../../public/locales/en-GB/translation.toml",
|
||||
"../../../public/locales/en-US/translation.toml",
|
||||
);
|
||||
|
||||
const IGNORED_DIRS = new Set(["tests", "__mocks__"]);
|
||||
@@ -174,14 +174,14 @@ const extractKeys = (file: string): FoundKey[] => {
|
||||
|
||||
describe("Missing translation coverage", () => {
|
||||
test(
|
||||
"fails if any en-GB translation key used in source is missing",
|
||||
"fails if any en-US translation key used in source is missing",
|
||||
{ timeout: 10000 },
|
||||
() => {
|
||||
expect(fs.existsSync(EN_GB_FILE)).toBe(true);
|
||||
expect(fs.existsSync(EN_US_FILE)).toBe(true);
|
||||
|
||||
const localeContent = fs.readFileSync(EN_GB_FILE, "utf8");
|
||||
const enGb = parse(localeContent);
|
||||
const availableKeys = flattenKeys(enGb);
|
||||
const localeContent = fs.readFileSync(EN_US_FILE, "utf8");
|
||||
const enUs = parse(localeContent);
|
||||
const availableKeys = flattenKeys(enUs);
|
||||
|
||||
const usedKeys = listSourceFiles()
|
||||
.flatMap(extractKeys)
|
||||
@@ -211,7 +211,7 @@ describe("Missing translation coverage", () => {
|
||||
// Output errors in GitHub Annotations format so they appear tagged in the code in CI
|
||||
for (const { key, fallback, file, line, column } of annotations) {
|
||||
process.stderr.write(
|
||||
`::error file=${file},line=${line},col=${column}::Missing en-GB translation for ${key} (${fallback})\n`,
|
||||
`::error file=${file},line=${line},col=${column}::Missing en-US translation for ${key} (${fallback})\n`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ test.describe("OAuth/SSO login buttons", () => {
|
||||
route.fulfill({
|
||||
json: {
|
||||
enableLogin: true,
|
||||
languages: ["en-GB"],
|
||||
defaultLocale: "en-GB",
|
||||
languages: ["en-US"],
|
||||
defaultLocale: "en-US",
|
||||
oauth2: {
|
||||
enabled: true,
|
||||
providers: [
|
||||
|
||||
@@ -6,9 +6,9 @@ import { parse } from "smol-toml";
|
||||
|
||||
const REPO_ROOT = path.join(__dirname, "../../../..");
|
||||
const SRC_ROOT = path.join(__dirname, "../..");
|
||||
const EN_GB_FILE = path.join(
|
||||
const EN_US_FILE = path.join(
|
||||
__dirname,
|
||||
"../../../public/locales/en-GB/translation.toml",
|
||||
"../../../public/locales/en-US/translation.toml",
|
||||
);
|
||||
|
||||
const IGNORED_DIRS = new Set(["tests", "__mocks__"]);
|
||||
@@ -151,13 +151,13 @@ const isIgnored = (key: string): boolean => {
|
||||
|
||||
describe("Unused translation coverage", () => {
|
||||
test(
|
||||
"fails if any en-GB translation key has no source references",
|
||||
"fails if any en-US translation key has no source references",
|
||||
{ timeout: 30_000 },
|
||||
() => {
|
||||
expect(fs.existsSync(EN_GB_FILE)).toBe(true);
|
||||
expect(fs.existsSync(EN_US_FILE)).toBe(true);
|
||||
|
||||
const enGb = parse(fs.readFileSync(EN_GB_FILE, "utf8"));
|
||||
const availableKeys = Array.from(flattenKeys(enGb));
|
||||
const enUs = parse(fs.readFileSync(EN_US_FILE, "utf8"));
|
||||
const availableKeys = Array.from(flattenKeys(enUs));
|
||||
expect(availableKeys.length).toBeGreaterThan(100); // sanity check
|
||||
|
||||
const sourceFiles = listSourceFiles();
|
||||
@@ -184,20 +184,20 @@ describe("Unused translation coverage", () => {
|
||||
});
|
||||
|
||||
const localeRelative = path
|
||||
.relative(REPO_ROOT, EN_GB_FILE)
|
||||
.relative(REPO_ROOT, EN_US_FILE)
|
||||
.replace(/\\/g, "/");
|
||||
|
||||
// GitHub Annotations format so unused keys show up tagged on the
|
||||
// translation file in CI.
|
||||
for (const key of unused) {
|
||||
process.stderr.write(
|
||||
`::error file=${localeRelative}::Unused en-GB translation: ${key}\n`,
|
||||
`::error file=${localeRelative}::Unused en-US translation: ${key}\n`,
|
||||
);
|
||||
}
|
||||
|
||||
expect(
|
||||
unused,
|
||||
`Found ${unused.length} unused en-GB translation key(s). ` +
|
||||
`Found ${unused.length} unused en-US translation key(s). ` +
|
||||
`Remove them from ${localeRelative}, or (if the usage is too ` +
|
||||
`dynamic for the heuristic to spot) add to IGNORED_KEY_PATTERNS ` +
|
||||
`in this test.`,
|
||||
|
||||
Reference in New Issue
Block a user