@ngx-runtime-i18n/core 1.0.3 → 1.0.4

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 +64 -15
  2. package/package.json +15 -1
package/README.md CHANGED
@@ -1,31 +1,80 @@
1
- # @ngx-runtime-i18n
1
+ # @ngx-runtime-i18n/core
2
2
 
3
- Lightweight runtime internationalization core (framework-agnostic).
3
+ Framework‑agnostic primitives for runtime internationalisation:
4
4
 
5
- Provides the core ICU-like formatting engine and catalog management.
5
+ - Tiny, dependency‑free **ICU‑lite** formatter (interpolation + basic `plural`).
6
+ - Shared types used by the Angular wrapper.
7
+
8
+ This package is designed to be used directly or via `@ngx-runtime-i18n/angular`.
9
+
10
+ ---
6
11
 
7
12
  ## Install
8
13
 
9
14
  ```bash
10
- npm i @ngx-runtime-i18n
15
+ npm i @ngx-runtime-i18n/core
11
16
  ```
12
17
 
13
- ## Usage
18
+ ---
19
+
20
+ ## Quick Start
14
21
 
15
22
  ```ts
16
- import { formatIcu } from '@ngx-runtime-i18n/core';
23
+ import { formatIcu, type Catalog } from '@ngx-runtime-i18n/core';
17
24
 
18
- const catalog = {
19
- hello: 'Hello {name}!',
20
- 'cart.items': '{count, plural, =0 {No items} one {1 item} other {# items}} in your cart',
25
+ const catalog: Catalog = {
26
+ hello: { user: 'Hello, {name}!' },
27
+ cart: { items: '{count, plural, one {1 item} other {# items}}' },
21
28
  };
22
29
 
23
- formatIcu('en', 'hello', catalog, { name: 'Ashwin' });
24
- // "Hello Ashwin!"
30
+ formatIcu('en', 'hello.user', catalog, { name: 'Ashwin' }); // "Hello, Ashwin!"
31
+ formatIcu('en', 'cart.items', catalog, { count: 2 }); // "2 items"
25
32
  ```
26
33
 
27
- This package contains:
34
+ - `key` supports dotted paths (e.g., `hello.user`).
35
+ - `plural` supports `one`, `other`, and exact matches like `=0`, `=2`.
36
+ - The function is pure and side‑effect free.
37
+
38
+ ---
39
+
40
+ ## API
41
+
42
+ ### `formatIcu(lang, key, catalog, params?, onMissingKey?)`
43
+
44
+ - **`lang: string`** — current language (for plural rules and future features).
45
+ - **`key: string`** — dotted path into the catalog.
46
+ - **`catalog: Catalog`** — a nested object of strings/objects.
47
+ - **`params?: Record<string, unknown>`** — interpolation values.
48
+ - **`onMissingKey?: (key: string) => string`** — transform for missing keys (defaults to returning the key).
49
+
50
+ ### Types
51
+
52
+ - **`Catalog`** — `Record<string, unknown>` (nested object).
53
+ - **`RuntimeI18nConfig`** — shape shared with the Angular wrapper for consistency.
54
+
55
+ ---
56
+
57
+ ## Catalog structure
58
+
59
+ ```json
60
+ {
61
+ "hello": { "user": "Hello, {name}!" },
62
+ "cart": { "items": "{count, plural, one {1 item} other {# items}}" }
63
+ }
64
+ ```
65
+
66
+ > Keep catalogs per language (e.g., `en.json`, `hi.json`).
67
+
68
+ ---
69
+
70
+ ## Pitfalls & Notes
71
+
72
+ - Not a full ICU implementation; aims to cover common 80% with a tiny footprint.
73
+ - If you need Angular binding or SSR helpers, prefer `@ngx-runtime-i18n/angular`.
74
+ - Keep your catalogs **flat-ish and predictable** to avoid fragile deep paths.
75
+
76
+ ---
77
+
78
+ ## License
28
79
 
29
- - `formatIcu(lang, key, catalog, params, onMissingKey?)`
30
- - Type definitions (`Catalog`, `RuntimeI18nConfig`)
31
- - Utilities for Angular bindings (`@ngx-runtime-i18n/angular`)
80
+ MIT
package/package.json CHANGED
@@ -1,9 +1,23 @@
1
1
  {
2
2
  "name": "@ngx-runtime-i18n/core",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Runtime i18n core with ICU-lite formatting",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
+ "keywords": [
8
+ "angular",
9
+ "i18n",
10
+ "internationalization",
11
+ "icu",
12
+ "runtime",
13
+ "ssr",
14
+ "signals"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/AshwinSathian/ngx-runtime-i18n.git"
19
+ },
20
+ "license": "MIT",
7
21
  "exports": {
8
22
  ".": {
9
23
  "import": "./fesm2022/ngx-runtime-i18n-core.mjs",