Skip to content

Commit d3b7be4

Browse files
committed
chore: remove old code
1 parent f7d43e0 commit d3b7be4

6 files changed

Lines changed: 12 additions & 49 deletions

File tree

cmp/compiler/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ The compiler is organized into several key modules:
3737
#### `src/plugin/` - Build-time transformation
3838

3939
- **`transform/`** - Babel AST transformation logic for JSX text extraction
40-
- **`unplugin.ts`** - Universal plugin implementation (Vite, Webpack, Rollup, esbuild)
41-
- **`next.ts`** - Next.js-specific plugin with Turbopack and webpack support
40+
- **`unplugin.ts`** - Universal plugin implementation (Vite, Webpack)
41+
- **`next.ts`** - Next.js-specific plugin with Turbopack and Webpack support
4242
- **`build-translator.ts`** - Batch translation generation at build time
43-
- **`locale-code-generator.ts`** - Generates locale resolver modules
43+
- **`virtual-modules-code-generator.ts`** - Generates code for virtual modules, dev config and locale resolvers for client and server
4444

4545
#### `src/metadata/` - Translation metadata management
4646

4747
- **`manager.ts`** - CRUD operations for `.lingo/metadata.json`
48-
- Thread-safe metadata file operations with locking
48+
- Thread-safe metadata file operations with file locking
4949
- Manages translation entries with hash-based identifiers
5050

5151
#### `src/translators/` - Translation provider abstraction

cmp/compiler/src/react/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ Context provider that manages translations and locale switching for your entire
1313
- `initialLocale` (string, required): Initial locale to use (e.g., 'en', 'de', 'fr')
1414
- `sourceLocale` (string, optional): Source language, default: 'en'
1515
- `initialTranslations` (object, optional): Pre-loaded translations
16-
- `fetchTranslations` (function, optional): Custom translation fetch function
17-
- `batchDelay` (number, optional): Debounce delay for batching requests in ms, default: 100
16+
- `fetchTranslations` (function, optional): Custom translation fetch function ms, default: 100
1817

1918
**Example:**
2019

cmp/compiler/src/react/shared/TranslationContext.tsx

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import {
1212
import { logger } from "../../utils/logger";
1313
import type { LingoDevState } from "../../widget/types";
1414
import { fetchTranslations } from "./utils";
15-
import type { CookieConfig } from "../../types";
16-
import { defaultCookieConfig } from "../../utils/cookies";
1715
import { serverUrl } from "@lingo.dev/compiler/dev-config";
1816
import {
1917
getClientLocale,
@@ -90,16 +88,6 @@ export interface TranslationProviderProps {
9088
*/
9189
initialTranslations?: Record<string, string>;
9290

93-
/**
94-
* Debounce delay for batching translation requests (ms)
95-
* Default: 100ms
96-
*/
97-
batchDelay?: number;
98-
/**
99-
* Cookie configuration for persisting locale
100-
*/
101-
cookieConfig?: CookieConfig;
102-
10391
/**
10492
* Optional router instance for Next.js integration
10593
* If provided, calls router.refresh() after locale change
@@ -128,6 +116,7 @@ export interface TranslationProviderProps {
128116
}
129117

130118
const IS_DEV = process.env.NODE_ENV === "development";
119+
const BATCH_DELAY = 200;
131120

132121
/**
133122
* Translation Provider Component
@@ -162,11 +151,9 @@ function TranslationProvider__Prod({
162151
initialLocale,
163152
sourceLocale = "en",
164153
initialTranslations = {},
165-
cookieConfig: customCookieConfig,
166154
router,
167155
children,
168156
}: TranslationProviderProps) {
169-
const [cookieConfig] = useState(customCookieConfig || defaultCookieConfig);
170157
// Use client locale detection if no initialLocale provided
171158
const [locale, setLocaleState] = useState(() => {
172159
if (initialLocale) return initialLocale;
@@ -270,7 +257,7 @@ function TranslationProvider__Prod({
270257
await loadTranslations(newLocale);
271258
}
272259
},
273-
[cookieConfig, router, loadTranslations],
260+
[router, loadTranslations],
274261
);
275262

276263
return (
@@ -293,13 +280,10 @@ function TranslationProvider__Dev({
293280
initialLocale,
294281
sourceLocale = "en",
295282
initialTranslations = {},
296-
batchDelay = 100,
297-
cookieConfig: customCookieConfig,
298283
router,
299284
devWidget,
300285
children,
301286
}: TranslationProviderProps) {
302-
const [cookieConfig] = useState(customCookieConfig || defaultCookieConfig);
303287
// Use client locale detection if no initialLocale provided
304288
const [locale, setLocaleState] = useState(() => {
305289
if (initialLocale) {
@@ -441,8 +425,8 @@ function TranslationProvider__Dev({
441425
} finally {
442426
setIsLoading(false);
443427
}
444-
}, batchDelay);
445-
}, [allSeenHashes, locale, sourceLocale, batchDelay, translations]);
428+
}, BATCH_DELAY);
429+
}, [allSeenHashes, locale, sourceLocale, translations]);
446430

447431
/**
448432
* Clear batch timer on unmount
@@ -504,7 +488,7 @@ function TranslationProvider__Dev({
504488
setIsLoading(false);
505489
}
506490
},
507-
[cookieConfig, router],
491+
[router],
508492
);
509493

510494
// Load widget on client-side only (avoids SSR issues with HTMLElement)

cmp/compiler/src/utils/cookies.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

cmp/compiler/src/utils/hash.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import crypto from "crypto";
22

33
/*
4-
* TODO
54
* If we find md5 too slow, we can use FNV-1a
5+
*
66
* function generateHash(text: string): string {
77
* let hash = 2166136261;
88
* for (let i = 0; i < text.length; i++) {
@@ -16,7 +16,7 @@ import crypto from "crypto";
1616

1717
/**
1818
* Generate a hash for a translation entry
19-
* Hash is based on: sourceText + componentName + filePath
19+
* Hash is based on: sourceText + context
2020
* This ensures that the same text in different components or files gets different hashes
2121
*/
2222
export function generateTranslationHash(

cmp/compiler/src/utils/path-helpers.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,3 @@ export function getLingoDir(config: PathConfig): string {
7979
const rootPath = resolveAbsolutePath(config.sourceRoot);
8080
return path.join(rootPath, config.lingoDir);
8181
}
82-
83-
export function getLocaleResolverPath(config: PathConfig): string {
84-
// TODO (AleksandrSl 01/12/2025): Why node resolves relative path as shit? .app with join turns into app/, while resolve gets the full path.
85-
return `${config.sourceRoot}/${config.lingoDir}/locale-resolver.ts`;
86-
}
87-
88-
export function getDevConfigPath(config: PathConfig): string {
89-
return `${config.sourceRoot}/${config.lingoDir}/dev-config.ts`;
90-
}

0 commit comments

Comments
 (0)