Skip to content

Commit 18ef68f

Browse files
committed
feat: vNext Lingo localizer
1 parent 79d258d commit 18ef68f

10 files changed

Lines changed: 369 additions & 70 deletions

File tree

.changeset/sixty-meteors-appear.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@lingo.dev/_spec": minor
3+
"lingo.dev": minor
4+
---
5+
6+
vNext localizer

demo/new-compiler-next16/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
},
1111
"dependencies": {
1212
"@lingo.dev/compiler": "workspace:*",
13-
"next": "^16.0.4",
13+
"next": "16.0.4",
1414
"react": "19.2.0",
1515
"react-dom": "19.2.0"
1616
},
1717
"devDependencies": {
18-
"@tailwindcss/postcss": "^4",
19-
"@types/node": "^20",
20-
"@types/react": "^19",
21-
"@types/react-dom": "^19",
22-
"eslint": "^9",
18+
"@tailwindcss/postcss": "4",
19+
"@types/node": "20",
20+
"@types/react": "19",
21+
"@types/react-dom": "19",
22+
"eslint": "9",
2323
"eslint-config-next": "16.0.3",
24-
"tailwindcss": "^4",
25-
"tsx": "^4.20.6",
26-
"typescript": "^5"
24+
"tailwindcss": "4",
25+
"tsx": "4.20.6",
26+
"typescript": "5"
2727
}
2828
}

demo/new-compiler-vite-react-spa/package.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@
99
},
1010
"dependencies": {
1111
"@lingo.dev/compiler": "workspace:*",
12-
"@tailwindcss/vite": "^4.0.6",
13-
"@tanstack/react-devtools": "^0.7.0",
14-
"@tanstack/react-router": "^1.132.0",
15-
"@tanstack/react-router-devtools": "^1.132.0",
16-
"@tanstack/router-plugin": "^1.132.0",
17-
"lucide-react": "^0.545.0",
18-
"react": "^19.2.0",
19-
"react-dom": "^19.2.0",
20-
"tailwindcss": "^4.0.6"
12+
"@tailwindcss/vite": "4.0.6",
13+
"@tanstack/react-devtools": "0.7.0",
14+
"@tanstack/react-router": "1.132.0",
15+
"@tanstack/react-router-devtools": "1.132.0",
16+
"@tanstack/router-plugin": "1.132.0",
17+
"lucide-react": "0.545.0",
18+
"react": "19.2.0",
19+
"react-dom": "19.2.0",
20+
"tailwindcss": "4.0.6"
2121
},
2222
"devDependencies": {
23-
"@tanstack/devtools-vite": "^0.3.11",
24-
"@testing-library/dom": "^10.4.0",
25-
"@testing-library/react": "^16.2.0",
26-
"@types/node": "^22.10.2",
27-
"@types/react": "^19.2.0",
28-
"@types/react-dom": "^19.2.0",
29-
"@vitejs/plugin-react": "^5.0.4",
30-
"jsdom": "^27.0.0",
31-
"typescript": "^5.7.2",
32-
"vite": "^7.3.0",
33-
"web-vitals": "^5.1.0"
23+
"@tanstack/devtools-vite": "0.3.11",
24+
"@testing-library/dom": "10.4.0",
25+
"@testing-library/react": "16.2.0",
26+
"@types/node": "22.10.2",
27+
"@types/react": "19.2.0",
28+
"@types/react-dom": "19.2.0",
29+
"@vitejs/plugin-react": "5.0.4",
30+
"jsdom": "27.0.0",
31+
"typescript": "5.7.2",
32+
"vite": "7.3.0",
33+
"web-vitals": "5.1.0"
3434
}
3535
}

packages/cli/src/cli/cmd/run/setup.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,15 @@ export default async function setup(input: CmdRunContext) {
5151
title: "Selecting localization provider",
5252
task: async (ctx, task) => {
5353
const provider = ctx.flags.pseudo ? "pseudo" : ctx.config?.provider;
54-
ctx.localizer = createLocalizer(provider, ctx.flags.apiKey);
54+
const vNext = ctx.config?.vNext;
55+
ctx.localizer = createLocalizer(provider, ctx.flags.apiKey, vNext);
5556
if (!ctx.localizer) {
5657
throw new Error(
5758
"Could not create localization provider. Please check your i18n.json configuration.",
5859
);
5960
}
6061
task.title =
61-
ctx.localizer.id === "Lingo.dev"
62+
ctx.localizer.id === "Lingo.dev" || ctx.localizer.id === "Lingo.dev vNext"
6263
? `Using ${chalk.hex(colors.green)(ctx.localizer.id)} provider`
6364
: ctx.localizer.id === "pseudo"
6465
? `Using ${chalk.hex(colors.blue)("pseudo")} mode for testing`
@@ -68,7 +69,7 @@ export default async function setup(input: CmdRunContext) {
6869
{
6970
title: "Checking authentication",
7071
enabled: (ctx) =>
71-
ctx.localizer?.id === "Lingo.dev" && !ctx.flags.pseudo,
72+
(ctx.localizer?.id === "Lingo.dev" || ctx.localizer?.id === "Lingo.dev vNext") && !ctx.flags.pseudo,
7273
task: async (ctx, task) => {
7374
const authStatus = await ctx.localizer!.checkAuth();
7475
if (!authStatus.authenticated) {
@@ -81,7 +82,7 @@ export default async function setup(input: CmdRunContext) {
8182
},
8283
{
8384
title: "Validating configuration",
84-
enabled: (ctx) => ctx.localizer?.id !== "Lingo.dev",
85+
enabled: (ctx) => ctx.localizer?.id !== "Lingo.dev" && ctx.localizer?.id !== "Lingo.dev vNext",
8586
task: async (ctx, task) => {
8687
const validationStatus = await ctx.localizer!.validateSettings!();
8788
if (!validationStatus.valid) {

packages/cli/src/cli/localizer/_types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export type LocalizerProgressFn = (
1616
) => void;
1717

1818
export interface ILocalizer {
19-
id: "Lingo.dev" | "pseudo" | NonNullable<I18nConfig["provider"]>["id"];
19+
id: "Lingo.dev" | "Lingo.dev vNext" | "pseudo" | NonNullable<I18nConfig["provider"]>["id"];
2020
checkAuth: () => Promise<{
2121
authenticated: boolean;
2222
username?: string;

packages/cli/src/cli/localizer/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
import { I18nConfig } from "@lingo.dev/_spec";
22

33
import createLingoDotDevLocalizer from "./lingodotdev";
4+
import createLingoDotDevVNextLocalizer from "./lingodotdev-vnext";
45
import createExplicitLocalizer from "./explicit";
56
import createPseudoLocalizer from "./pseudo";
67
import { ILocalizer } from "./_types";
78

89
export default function createLocalizer(
910
provider: I18nConfig["provider"] | "pseudo" | null | undefined,
1011
apiKey?: string,
12+
vNext?: string,
1113
): ILocalizer {
1214
if (provider === "pseudo") {
1315
return createPseudoLocalizer();
1416
}
1517

18+
// Check if vNext is configured
19+
if (vNext) {
20+
return createLingoDotDevVNextLocalizer(vNext);
21+
}
22+
1623
if (!provider) {
1724
return createLingoDotDevLocalizer(apiKey);
1825
} else {

0 commit comments

Comments
 (0)