@better-i18n/core 0.1.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.
Files changed (2) hide show
  1. package/README.md +65 -0
  2. package/package.json +50 -0
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # @better-i18n/core
2
+
3
+ Framework-agnostic core utilities for fetching translations from Better i18n CDN.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @better-i18n/core
9
+ # or
10
+ bun add @better-i18n/core
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```typescript
16
+ import { createI18nCore } from '@better-i18n/core'
17
+
18
+ const i18n = createI18nCore({
19
+ project: 'your-org/your-project',
20
+ defaultLocale: 'en',
21
+ })
22
+
23
+ // Fetch messages for a locale
24
+ const messages = await i18n.getMessages('en')
25
+
26
+ // Get available locales
27
+ const locales = await i18n.getLocales()
28
+ // ['en', 'tr', 'de', ...]
29
+
30
+ // Get language options with metadata (for UI)
31
+ const languages = await i18n.getLanguages()
32
+ // [{ code: 'en', name: 'English', nativeName: 'English', flagUrl: '...' }, ...]
33
+
34
+ // Get manifest
35
+ const manifest = await i18n.getManifest()
36
+ ```
37
+
38
+ ## Configuration
39
+
40
+ ```typescript
41
+ interface I18nCoreConfig {
42
+ // Required
43
+ project: string // "org/project" format
44
+ defaultLocale: string // e.g., "en"
45
+
46
+ // Optional
47
+ cdnBaseUrl?: string // default: "https://cdn.better-i18n.com"
48
+ manifestCacheTtlMs?: number // default: 300000 (5 minutes)
49
+ debug?: boolean // default: false
50
+ logLevel?: LogLevel // default: "warn"
51
+ fetch?: typeof fetch // custom fetch function
52
+ }
53
+ ```
54
+
55
+ ## Used By
56
+
57
+ This package is the foundation for:
58
+
59
+ - `@better-i18n/next` - Next.js integration
60
+ - `@better-i18n/use-intl` - TanStack/React integration
61
+ - `@better-i18n/i18next-backend` - i18next backend plugin
62
+
63
+ ## License
64
+
65
+ MIT
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@better-i18n/core",
3
+ "version": "0.1.2",
4
+ "description": "Framework-agnostic core utilities for Better i18n",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/better-i18n/better-i18n.git",
9
+ "directory": "packages/core"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/better-i18n/better-i18n/issues"
13
+ },
14
+ "homepage": "https://github.com/better-i18n/better-i18n/tree/main/packages/i18n-core",
15
+ "type": "module",
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ },
23
+ "./package.json": "./package.json"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "package.json",
28
+ "README.md"
29
+ ],
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "keywords": [
34
+ "i18n",
35
+ "localization",
36
+ "internationalization",
37
+ "cdn",
38
+ "translations"
39
+ ],
40
+ "scripts": {
41
+ "build": "tsc",
42
+ "typecheck": "tsc --noEmit",
43
+ "clean": "rm -rf dist"
44
+ },
45
+ "devDependencies": {
46
+ "@better-i18n/typescript-config": "workspace:*",
47
+ "@types/node": "^20.0.0",
48
+ "typescript": "~5.9.2"
49
+ }
50
+ }