@nckdv/translation-core 0.2.0 → 0.2.1

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 +44 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # `@nckdv/translation-core`
2
+
3
+ The framework-agnostic translation engine behind nck-translation: key lookup,
4
+ fallback, and `{placeholder}` interpolation. It does no I/O — you supply the
5
+ messages.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @nckdv/translation-core
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { createTranslator } from "@nckdv/translation-core";
17
+
18
+ const t = createTranslator({
19
+ language: "de",
20
+ messages: { "home.title": "Willkommen", "cart.total": "Gesamt: {amount}" },
21
+ fallback: { "home.title": "Welcome", "buttons.save": "Save" },
22
+ });
23
+
24
+ t("home.title"); // "Willkommen"
25
+ t("buttons.save"); // "Save" (from fallback)
26
+ t("cart.total", { amount: "42,00 €" }); // "Gesamt: 42,00 €"
27
+ t("unknown.key"); // "unknown.key" (renders its own name)
28
+ ```
29
+
30
+ ## Notes
31
+
32
+ - **No I/O.** It never fetches or reads the environment — pass in already-loaded
33
+ catalogs. Loading and caching live in `@nckdv/translation-sdk`.
34
+ - **Fallback** fills keys the active language is missing.
35
+ - A **missing key renders as its own name** instead of throwing or blanking —
36
+ loud enough to catch in review, quiet enough not to break the page. Override
37
+ with `onMissingKey`.
38
+ - Placeholders are `{name}`, filled from the second argument.
39
+
40
+ ## Family
41
+
42
+ - `@nckdv/translation-sdk` — fetch + cache catalogs from the API, and push.
43
+ - `@nckdv/translation-react` — React provider + hooks over this engine.
44
+ - `@nckdv/translation-nextjs` — Next.js server integration.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nckdv/translation-core",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Framework-agnostic translation engine: lookup, fallback, interpolation.",
5
5
  "type": "module",
6
6
  "license": "MIT",