@sonenta/react-i18next 2.3.0 → 2.3.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/dist/index.cjs +13 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +13 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -178,10 +178,10 @@ interface SonentaConfig {
|
|
|
178
178
|
disableLanguageCatalog?: boolean;
|
|
179
179
|
/**
|
|
180
180
|
* Skip the best-effort fetch of the per-version published-languages manifest
|
|
181
|
-
* (`{
|
|
182
|
-
* that powers `i18n.availableLanguages` /
|
|
183
|
-
* skipped (or on a 404), `availableLanguages`
|
|
184
|
-
* `defaultLocale` + `fallbackLng`.
|
|
181
|
+
* (`{apiBase}/cdn/v1/{project}/{version}/latest/languages.json`, public, no
|
|
182
|
+
* auth, CORS-open) that powers `i18n.availableLanguages` /
|
|
183
|
+
* `useAvailableLanguages()`. When skipped (or on a 404), `availableLanguages`
|
|
184
|
+
* falls back to the configured `defaultLocale` + `fallbackLng`.
|
|
185
185
|
*/
|
|
186
186
|
disableLanguageManifest?: boolean;
|
|
187
187
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -178,10 +178,10 @@ interface SonentaConfig {
|
|
|
178
178
|
disableLanguageCatalog?: boolean;
|
|
179
179
|
/**
|
|
180
180
|
* Skip the best-effort fetch of the per-version published-languages manifest
|
|
181
|
-
* (`{
|
|
182
|
-
* that powers `i18n.availableLanguages` /
|
|
183
|
-
* skipped (or on a 404), `availableLanguages`
|
|
184
|
-
* `defaultLocale` + `fallbackLng`.
|
|
181
|
+
* (`{apiBase}/cdn/v1/{project}/{version}/latest/languages.json`, public, no
|
|
182
|
+
* auth, CORS-open) that powers `i18n.availableLanguages` /
|
|
183
|
+
* `useAvailableLanguages()`. When skipped (or on a 404), `availableLanguages`
|
|
184
|
+
* falls back to the configured `defaultLocale` + `fallbackLng`.
|
|
185
185
|
*/
|
|
186
186
|
disableLanguageManifest?: boolean;
|
|
187
187
|
/**
|
package/dist/index.js
CHANGED
|
@@ -46,7 +46,9 @@ async function loadCatalog(apiBase, fetchImpl = fetch) {
|
|
|
46
46
|
const r = await fetchImpl(url, { method: "GET", credentials: "omit" });
|
|
47
47
|
if (!r.ok) return null;
|
|
48
48
|
const data = await r.json();
|
|
49
|
-
|
|
49
|
+
if (Array.isArray(data)) return data;
|
|
50
|
+
const items = data?.items;
|
|
51
|
+
return Array.isArray(items) ? items : null;
|
|
50
52
|
} catch {
|
|
51
53
|
return null;
|
|
52
54
|
}
|
|
@@ -210,7 +212,7 @@ function flattenPlurals(tree, locale) {
|
|
|
210
212
|
|
|
211
213
|
// src/transport.ts
|
|
212
214
|
var SDK_LIB = "@sonenta/react-i18next";
|
|
213
|
-
var SDK_VER = true ? "2.3.
|
|
215
|
+
var SDK_VER = true ? "2.3.2" : "0.0.0-dev";
|
|
214
216
|
function defaultTransport(opts) {
|
|
215
217
|
return async (batch) => {
|
|
216
218
|
if (!batch.length) return;
|
|
@@ -747,16 +749,18 @@ var SonentaI18n = class {
|
|
|
747
749
|
* Skipped when disabled; a failure keeps any embedded catalog. */
|
|
748
750
|
/**
|
|
749
751
|
* Best-effort: fetch the per-version published-languages manifest
|
|
750
|
-
* (`{
|
|
751
|
-
* CDN-cached) — the SET of locales
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
752
|
+
* (`{apiBase}/cdn/v1/{project}/{version}/latest/languages.json`, public, no
|
|
753
|
+
* auth, CORS-open, CDN-cached `max-age=60` + ETag) — the SET of locales
|
|
754
|
+
* published for the active version (compute-on-serve from cdn_releases,
|
|
755
|
+
* always in sync with what is published). Codes only; enriched from the
|
|
756
|
+
* catalog. A 404/offline keeps any prior manifest (`availableLanguages` then
|
|
757
|
+
* falls back to default + fallback). Same route on prod + dev (backend task
|
|
758
|
+
* 989+; the authed `/v1/projects/{id}/languages` is ALL project languages,
|
|
759
|
+
* not the published set — this manifest is the in-production set).
|
|
755
760
|
*/
|
|
756
761
|
async _loadManifest(fetchImpl, opts = {}) {
|
|
757
762
|
if (this._manifestDisabled) return;
|
|
758
|
-
|
|
759
|
-
const url = `${this._config.cdnBase.replace(/\/+$/, "")}/p/${this._config.projectUuid}/${this._config.version}/latest/languages.json`;
|
|
763
|
+
const url = `${this._config.apiBase.replace(/\/+$/, "")}/cdn/v1/${this._config.projectUuid}/${this._config.version}/latest/languages.json`;
|
|
760
764
|
const init = { method: "GET", credentials: "omit" };
|
|
761
765
|
if (opts.bust) init.cache = "reload";
|
|
762
766
|
try {
|