@sonenta/react-i18next 2.0.0 → 2.1.0

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![MIT licensed](https://img.shields.io/npm/l/@sonenta/react-i18next.svg)](./LICENSE)
4
4
 
5
- The React SDK for [Sonenta](https://verbumia.ca). Resolve translations from
5
+ The React SDK for [Sonenta](https://sonenta.com). Resolve translations from
6
6
  the Sonenta CDN, fall back gracefully when a key is missing, and stream those
7
7
  missing keys back to your dashboard in real time so the team can fill them
8
8
  without redeploying.
@@ -19,6 +19,36 @@ npm install @sonenta/react-i18next
19
19
 
20
20
  ---
21
21
 
22
+ ## Drop-in replacement for react-i18next
23
+
24
+ Already on **react-i18next**? Switch in two steps. Your existing
25
+ `useTranslation`, `t()`, and `<Trans>` calls keep working unchanged.
26
+
27
+ **1. Repoint the import** — one find-and-replace across your codebase:
28
+
29
+ ```diff
30
+ - import { useTranslation, Trans } from "react-i18next";
31
+ + import { useTranslation, Trans } from "@sonenta/react-i18next";
32
+ ```
33
+
34
+ **2. Wrap your app once** in `<SonentaProvider>` (replacing `i18next.init` +
35
+ `I18nextProvider`). Translations now load from the Sonenta CDN and missing
36
+ keys stream to your dashboard — everything else stays the same:
37
+
38
+ ```tsx
39
+ import { SonentaProvider } from "@sonenta/react-i18next";
40
+
41
+ <SonentaProvider token={…} projectUuid={…} defaultLocale="fr" fallbackLng="en">
42
+ <App />
43
+ </SonentaProvider>
44
+ ```
45
+
46
+ No `i18next.init`, no backend module, no bundled JSON. See
47
+ [Migrating from react-i18next](#migrating-from-react-i18next) for the full
48
+ compatibility notes.
49
+
50
+ ---
51
+
22
52
  ## Quickstart
23
53
 
24
54
  ```tsx
@@ -27,8 +57,8 @@ import { SonentaProvider, useTranslation } from "@sonenta/react-i18next";
27
57
  export function App() {
28
58
  return (
29
59
  <SonentaProvider
30
- token={import.meta.env.VITE_VERBUMIA_TOKEN}
31
- projectUuid={import.meta.env.VITE_VERBUMIA_PROJECT}
60
+ token={import.meta.env.VITE_SONENTA_TOKEN}
61
+ projectUuid={import.meta.env.VITE_SONENTA_PROJECT}
32
62
  defaultLocale="fr"
33
63
  fallbackLng="en"
34
64
  namespaces={["common"]}
@@ -64,8 +94,8 @@ interface SonentaConfig {
64
94
  fallbackLng?: string | string[]; // fallback locale(s); variants also fall back to their base (fr-CA → fr)
65
95
  namespaces?: string[]; // default ['common']
66
96
  defaultNS?: string; // alias: default namespace for single-ns apps
67
- apiBase?: string; // default 'https://api.verbumia.dev'
68
- cdnBase?: string; // default 'https://cdn.verbumia.ca'
97
+ apiBase?: string; // default 'https://api.sonenta.com'
98
+ cdnBase?: string; // default 'https://cdn.sonenta.com'
69
99
  languageCatalog?: LanguageMeta[]; // embed the language catalog (offline/SSR/RN); powers dir()/nativeName()
70
100
  disableLanguageCatalog?: boolean; // skip the public GET /v1/languages fetch
71
101
  version?: string; // version slug, default 'main' (in cache keys)
@@ -382,7 +412,7 @@ import { sonentaRealtime } from "@sonenta/realtime/react";
382
412
  {...config}
383
413
  env="dev"
384
414
  plugins={[
385
- sonentaRealtime({ wsUrl: "wss://rt.verbumia.ca/connection/websocket" }),
415
+ sonentaRealtime({ wsUrl: "wss://rt.sonenta.dev/connection/websocket" }),
386
416
  ]}
387
417
  >
388
418
  <App />
@@ -425,7 +455,7 @@ from the snapshot do not fire "missing" reports until a real fetch confirms.
425
455
  - **CLI (recommended):** `verbumia snapshot` (from `@verbumia/cli`) fetches the
426
456
  current published bundles and writes the JSON module.
427
457
  - **Manual:** fetch each
428
- `https://cdn.verbumia.ca/p/<project>/<version>/latest/<locale>/<ns>.json` and
458
+ `https://cdn.sonenta.com/p/<project>/<version>/latest/<locale>/<ns>.json` and
429
459
  assemble them into `{ [locale]: { [namespace]: <tree> } }`, then import it.
430
460
 
431
461
  ## Surface variants
@@ -481,8 +511,8 @@ import { SonentaProvider } from "@sonenta/react-i18next";
481
511
  export function I18nClient({ children }: { children: React.ReactNode }) {
482
512
  return (
483
513
  <SonentaProvider
484
- token={process.env.NEXT_PUBLIC_VERBUMIA_TOKEN!}
485
- projectUuid={process.env.NEXT_PUBLIC_VERBUMIA_PROJECT!}
514
+ token={process.env.NEXT_PUBLIC_SONENTA_TOKEN!}
515
+ projectUuid={process.env.NEXT_PUBLIC_SONENTA_PROJECT!}
486
516
  defaultLocale="fr"
487
517
  fallbackLng="en"
488
518
  >
package/dist/index.cjs CHANGED
@@ -236,7 +236,7 @@ function flattenPlurals(tree, locale) {
236
236
 
237
237
  // src/transport.ts
238
238
  var SDK_LIB = "@sonenta/react-i18next";
239
- var SDK_VER = true ? "2.0.0" : "0.0.0-dev";
239
+ var SDK_VER = true ? "2.1.0" : "0.0.0-dev";
240
240
  function defaultTransport(opts) {
241
241
  return async (batch) => {
242
242
  if (!batch.length) return;
@@ -390,8 +390,8 @@ var KeyRegistry = class {
390
390
  var keyRegistry = new KeyRegistry();
391
391
 
392
392
  // src/i18n.ts
393
- var DEFAULT_API_BASE = "https://api.verbumia.dev";
394
- var DEFAULT_CDN_BASE = "https://cdn.verbumia.ca";
393
+ var DEFAULT_API_BASE = "https://api.sonenta.com";
394
+ var DEFAULT_CDN_BASE = "https://cdn.sonenta.com";
395
395
  var DEFAULT_FLUSH_MS = 5e3;
396
396
  var DEFAULT_BATCH = 50;
397
397
  var DEFAULT_BUFFER = 200;