@translation-cms/sync 1.1.77 → 1.1.81

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/i18next.js DELETED
@@ -1,74 +0,0 @@
1
- /**
2
- * i18next backend plugin for the Translations CMS.
3
- *
4
- * Automatically reads config from NEXT_PUBLIC_* env vars.
5
- * Supports both local file mode and direct CMS API mode.
6
- *
7
- * @example
8
- * ```ts
9
- * // lib/i18n.ts
10
- * import i18next from 'i18next';
11
- * import { initReactI18next } from 'react-i18next';
12
- * import { CMSBackend } from '@translation-cms/sync/i18next';
13
- *
14
- * i18next
15
- * .use(CMSBackend)
16
- * .use(initReactI18next)
17
- * .init({
18
- * lng: 'nl',
19
- * fallbackLng: 'en',
20
- * ns: ['common', 'auth'],
21
- * defaultNS: 'common',
22
- * });
23
- * ```
24
- */
25
- /**
26
- * i18next backend plugin.
27
- * Implements the i18next BackendModule interface.
28
- */
29
- export class CMSBackend {
30
- static type = 'backend';
31
- type = 'backend';
32
- options;
33
- constructor(_services, options = {}) {
34
- this.options = this.resolveOptions(options);
35
- }
36
- init(_services, options = {}) {
37
- this.options = this.resolveOptions(options);
38
- }
39
- read(language, namespace, callback) {
40
- this.readLocal(language, namespace, callback);
41
- }
42
- readLocal(language, namespace, callback) {
43
- const baseUrl = typeof window !== 'undefined'
44
- ? window.location.origin
45
- : `http://localhost:${(typeof process !== 'undefined' && process.env['PORT']) ||
46
- '3000'}`;
47
- // Single file per locale: /dictionaries/{locale}.json → extract namespace
48
- const url = `${baseUrl}${this.options.localePath}/${language}.json`;
49
- fetch(url)
50
- .then(r => {
51
- if (r.status === 404) {
52
- callback(null, {});
53
- return null;
54
- }
55
- if (!r.ok) {
56
- callback(new Error(`Failed to load local translations (${r.status}): ${url}`), null);
57
- return null;
58
- }
59
- return r.json();
60
- })
61
- .then(data => {
62
- if (!data)
63
- return;
64
- callback(null, data[namespace] ?? {});
65
- })
66
- .catch((err) => callback(err, null));
67
- }
68
- resolveOptions(options) {
69
- return {
70
- localePath: options.localePath ?? '/dictionaries',
71
- };
72
- }
73
- }
74
- //# sourceMappingURL=i18next.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"i18next.js","sourceRoot":"","sources":["../src/i18next.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAeH;;;GAGG;AACH,MAAM,OAAO,UAAU;IACnB,MAAM,CAAC,IAAI,GAAG,SAAkB,CAAC;IACjC,IAAI,GAAG,SAAkB,CAAC;IAElB,OAAO,CAA8B;IAE7C,YAAY,SAAkB,EAAE,UAA6B,EAAE;QAC3D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,CAAC,SAAkB,EAAE,UAA6B,EAAE;QACpD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,CAAC,QAAgB,EAAE,SAAiB,EAAE,QAAsB;QAC5D,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;IAEO,SAAS,CACb,QAAgB,EAChB,SAAiB,EACjB,QAAsB;QAEtB,MAAM,OAAO,GACT,OAAO,MAAM,KAAK,WAAW;YACzB,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM;YACxB,CAAC,CAAC,oBACI,CAAC,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBACvD,MACJ,EAAE,CAAC;QACb,0EAA0E;QAC1E,MAAM,GAAG,GAAG,GAAG,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,QAAQ,OAAO,CAAC;QAEpE,KAAK,CAAC,GAAG,CAAC;aACL,IAAI,CAAC,CAAC,CAAC,EAAE;YACN,IAAI,CAAC,CAAC,MAAM,KAAK,GA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