Skip to content

Commit 24ef708

Browse files
committed
chore: cleanup more stupid defaults
1 parent a16f982 commit 24ef708

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

cmp/compiler/src/plugin/transform/utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ export function isReactComponent(
5555
}
5656
}
5757

58-
// TODO (AleksandrSl 25/11/2025): In which order does it traverse? If it's DFS it may find the incorrect return?
58+
// Babel traverses with DFS so we get the innermost function return first if any.
59+
// But if at least one function returns JSX I guess we should transform the whole function.
60+
// It's a weird corner case.
61+
5962
// Check for explicit return statements with JSX
6063
// We could also check for the first JSX?
6164
let returnsJSX = false;
@@ -181,7 +184,6 @@ export function constructTranslationCall(
181184
t.arrowFunctionExpression([], element)
182185
: // Create: tagName: (chunks) => <Element>{chunks}</Element>
183186
t.arrowFunctionExpression(
184-
// TODO (AleksandrSl 28/11/2025): Use content instead of the chunks later
185187
[t.identifier("chunks")],
186188
t.jsxElement(
187189
t.jsxOpeningElement(

cmp/compiler/src/react/server-only/translations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async function readFromFilesystem(
4141
locale: LocaleCode,
4242
basePath: string = process.cwd(),
4343
): Promise<Record<string, string>> {
44-
// TODO (AleksandrSl 02/12/2025): Sanity check. We need to try loading the most up to date translations first. Fo the dev mode they are in lingo. Gor build they are in next.
44+
// TODO (AleksandrSl 15/12/2025): What should be the correct way here to load translations on server for other frameworks?
4545
const possiblePaths = [
4646
join(basePath, cacheDir, `${locale}.json`),
4747
join(basePath, ".next", `${locale}.json`),

cmp/compiler/src/translators/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export { PseudoTranslator } from "./pseudotranslator";
1212
export { Service } from "./lingo";
1313
export type { LingoTranslatorConfig } from "./lingo";
1414
export { createTranslator } from "./translator-factory";
15-
export type { TranslatorFactoryConfig } from "./translator-factory";
1615

1716
// Translation Service (orchestrator)
1817
export { TranslationService } from "./translation-service";

cmp/compiler/src/translators/lingo/service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import type { LocaleCode } from "lingo.dev/spec";
2525
export interface LingoTranslatorConfig {
2626
models: "lingo.dev" | Record<string, string>;
2727
sourceLocale: LocaleCode;
28-
prompt?: string | null;
28+
prompt?: string;
2929
}
3030

3131
/**
@@ -200,7 +200,7 @@ export class Service implements Translator<LingoTranslatorConfig> {
200200
content: getSystemPrompt({
201201
sourceLocale: this.config.sourceLocale,
202202
targetLocale,
203-
prompt: this.config.prompt ?? undefined,
203+
prompt: this.config.prompt,
204204
}),
205205
},
206206
// Add few-shot examples

cmp/compiler/src/translators/translator-factory.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import { PseudoTranslator } from "./pseudotranslator";
77
import { Service } from "./lingo";
88
import { Logger } from "../utils/logger";
99
import type { LocaleCode } from "lingo.dev/spec";
10+
import type { LingoEnvironment } from "../types";
1011

11-
export interface TranslatorFactoryConfig {
12+
interface TranslatorFactoryConfig {
1213
sourceLocale: LocaleCode;
13-
models?: "lingo.dev" | Record<string, string>;
14+
models: "lingo.dev" | Record<string, string>;
1415
prompt?: string;
15-
environment: "development" | "production";
16+
environment: LingoEnvironment;
1617
dev?: {
1718
usePseudotranslator?: boolean;
1819
};
@@ -39,7 +40,7 @@ export interface TranslatorFactoryConfig {
3940
export function createTranslator(
4041
config: TranslatorFactoryConfig,
4142
logger: Logger,
42-
): Translator<any> {
43+
): Translator<unknown> {
4344
const isDev = config.environment === "development";
4445

4546
// 1. Explicit dev override takes precedence
@@ -52,8 +53,7 @@ export function createTranslator(
5253
// LingoTranslator constructor will validate and fetch API keys
5354
// If validation fails, it will throw an error with helpful message
5455
try {
55-
// TODO (AleksandrSl 14/12/2025): Get rid of default
56-
const models = config.models || "lingo.dev";
56+
const models = config.models;
5757

5858
logger.info(
5959
`Creating Lingo translator with models: ${JSON.stringify(models)}`,
@@ -63,7 +63,7 @@ export function createTranslator(
6363
{
6464
models,
6565
sourceLocale: config.sourceLocale,
66-
prompt: config.prompt || null,
66+
prompt: config.prompt,
6767
},
6868
logger,
6969
);
@@ -72,8 +72,8 @@ export function createTranslator(
7272
if (isDev) {
7373
// Use console.error to ensure visibility in all contexts (loader, server, etc.)
7474
const errorMsg = error instanceof Error ? error.message : String(error);
75-
console.error(`\n❌ [Lingo] Translation setup error: ${errorMsg}\n`);
76-
console.warn(
75+
logger.error(`\n❌ [Lingo] Translation setup error: ${errorMsg}\n`);
76+
logger.warn(
7777
`⚠️ [Lingo] Auto-fallback to pseudotranslator in development mode.\n` +
7878
` Set the required API keys for real translations.\n`,
7979
);

0 commit comments

Comments
 (0)