@universal-i18n/core 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/package.json +7 -1
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @universal-i18n/core
|
|
2
|
+
|
|
3
|
+
The core translation engine for `universal-i18n`. This package provides the underlying translation mechanics, batching, caching, and retry logic.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @universal-i18n/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Multi-layer caching:** Memory, File System, Redis
|
|
14
|
+
- **Batching:** Coalesces multiple translation requests into a single network call
|
|
15
|
+
- **Retry Logic:** Exponential backoff for rate limits
|
|
16
|
+
- **Lingo.dev SDK:** Powered by the official `lingo.dev` engine
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { createEngine } from "@universal-i18n/core";
|
|
22
|
+
|
|
23
|
+
const engine = createEngine({
|
|
24
|
+
apiKey: process.env.LINGODOTDEV_API_KEY,
|
|
25
|
+
sourceLocale: "en",
|
|
26
|
+
cache: "memory", // 'memory' | 'fs' | 'redis' | custom
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const translated = await engine.translate({
|
|
30
|
+
texts: { hello: "Hello World" },
|
|
31
|
+
targetLocale: "es",
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
console.log(translated.hello); // "Hola Mundo"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## API Reference
|
|
38
|
+
|
|
39
|
+
See the [Mono-repo README](https://github.com/universal-i18n/universal-i18n) for full documentation.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@universal-i18n/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Core translation engine and multi-layer caching for universal-i18n",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
|
+
"browser": {
|
|
19
|
+
"fs": false,
|
|
20
|
+
"path": false,
|
|
21
|
+
"crypto": false,
|
|
22
|
+
"ioredis": false
|
|
23
|
+
},
|
|
18
24
|
"scripts": {
|
|
19
25
|
"build": "tsup",
|
|
20
26
|
"clean": "rimraf dist",
|