vbss-translator 1.0.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 +173 -0
- package/dist/vbss-translator.d.ts +27 -0
- package/dist/vbss-translator.js +665 -0
- package/dist/vbss-translator.umd.cjs +30 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# vbss-translator
|
|
2
|
+
|
|
3
|
+
A lightweight and customizable React translation hook to easily handle multilingual websites. Includes support for browser language auto-detection, local persistence of language, and customizable translation files.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Auto-detect browser language to set the initial language.
|
|
10
|
+
- Persist selected language in local storage.
|
|
11
|
+
- Customizable and dynamic translation keys.
|
|
12
|
+
- Minimalistic integration with React via useTranslator hook.
|
|
13
|
+
- Flexible and developer-friendly API.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Install the package using npm:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install vbss-translator
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
or yarn:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
yarn add vbss-translator
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
or Github Registry:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install @vbss-io/vbss-translator@0.0.1
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
*Github Registry may cause incompatibility with npm registry.*
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
### Setup the `TranslatorProvider`
|
|
44
|
+
|
|
45
|
+
Create a JSON file for translations. For example: `translations.json`
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
[
|
|
49
|
+
{
|
|
50
|
+
"en": {
|
|
51
|
+
"greeting": "Hello",
|
|
52
|
+
"goodbye": "Goodbye"
|
|
53
|
+
},
|
|
54
|
+
"pt": {
|
|
55
|
+
"greeting": "Olá",
|
|
56
|
+
"goodbye": "Adeus"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Wrap your application with the TranslatorProvider to make the translator context available throughout your app.
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import translations from './translations.json';
|
|
66
|
+
|
|
67
|
+
ReactDOM.render(
|
|
68
|
+
<TranslatorProvider translations={translations}>
|
|
69
|
+
<App />
|
|
70
|
+
</TranslatorProvider>,
|
|
71
|
+
document.getElementById('root')
|
|
72
|
+
);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Use the `useTranslator` Hook
|
|
76
|
+
|
|
77
|
+
The useTranslator hook provides access to the t function for translations and methods to manage the current language.
|
|
78
|
+
|
|
79
|
+
Example Usage in Components:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import React from 'react';
|
|
83
|
+
import { useTranslator } from 'react-simple-translator';
|
|
84
|
+
|
|
85
|
+
const ExampleComponent = () => {
|
|
86
|
+
const { t, setLanguage, language } = useTranslator();
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<div>
|
|
90
|
+
<h1>{t('Olá')}</h1>
|
|
91
|
+
<p>Current Language: {language}</p>
|
|
92
|
+
<button onClick={() => setLanguage('en')}>English</button>
|
|
93
|
+
<button onClick={() => setLanguage('pt')}>Português</button>
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export default ExampleComponent;
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Auto-Detect Browser Language
|
|
102
|
+
|
|
103
|
+
If you pass the autoDetectLanguage prop to TranslatorProvider, the library will detect the user's browser language automatically. The fallback language will be the defaultLanguage.
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
ReactDOM.render(
|
|
107
|
+
<TranslatorProvider
|
|
108
|
+
translations={translations}
|
|
109
|
+
defaultLanguage="en"
|
|
110
|
+
autoDetectLanguage
|
|
111
|
+
>
|
|
112
|
+
<App />
|
|
113
|
+
</TranslatorProvider>,
|
|
114
|
+
document.getElementById('root')
|
|
115
|
+
);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
For example:
|
|
119
|
+
|
|
120
|
+
- Browser language: pt-BR
|
|
121
|
+
- Default language: en
|
|
122
|
+
|
|
123
|
+
The app will automatically use English as default if not provided or browser language not available.
|
|
124
|
+
|
|
125
|
+
### Persisting the Selected Language
|
|
126
|
+
|
|
127
|
+
To persist the selected language across page reloads, use the persist as true and the optional persistKey prop. This will store the selected language in localStorage under the specified key.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
ReactDOM.render(
|
|
131
|
+
<TranslatorProvider
|
|
132
|
+
translations={translations}
|
|
133
|
+
persist
|
|
134
|
+
persistKey="myAppLanguage"
|
|
135
|
+
>
|
|
136
|
+
<App />
|
|
137
|
+
</TranslatorProvider>,
|
|
138
|
+
document.getElementById('root')
|
|
139
|
+
);
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
### **`TranslatorProvider` Props**
|
|
145
|
+
|
|
146
|
+
|Prop|Type|Default Value|Description|
|
|
147
|
+
|---|---|---|---|
|
|
148
|
+
|`translations`|`Record<string>[]`|Required|The translations JSON file or object.|
|
|
149
|
+
|`defaultLanguage`|`string`|`'en'`|The fallback/default language.|
|
|
150
|
+
|`autoDetectLanguage`|`boolean`|`false`|If true, detects the user's browser language automatically.|
|
|
151
|
+
|`persist`|`boolean`|`false`|If provided, persists the language in `localStorage` with persistKey.|
|
|
152
|
+
|`persistKey`|`string`|`language`|If provided, customize the `localStorage` key.|
|
|
153
|
+
|
|
154
|
+
### **`useTranslator` Hook**
|
|
155
|
+
|
|
156
|
+
The `useTranslator` hook provides the following:
|
|
157
|
+
|
|
158
|
+
|Property|Type|Description|
|
|
159
|
+
|---|---|---|
|
|
160
|
+
|`t`|`(text: string) => string`|Function to get the translated text for a given key.|
|
|
161
|
+
|`language`|`string`|The currently active language.|
|
|
162
|
+
|`languages`|`string[]`|The currently available languages.|
|
|
163
|
+
|`setLanguage`|`(lang: string) => void`|Function to change the current language.|
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Feedback
|
|
168
|
+
|
|
169
|
+
If you enjoy using this package or find any issues, please give us a ⭐ on GitHub or open an issue. We appreciate your support! 🚀
|
|
170
|
+
|
|
171
|
+
## Contributing
|
|
172
|
+
|
|
173
|
+
We welcome contributions! Feel free to open issues or submit pull requests.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
declare type Translation = {
|
|
4
|
+
[key: string]: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
declare type TranslatorContextType = {
|
|
8
|
+
t: (key: string) => string;
|
|
9
|
+
language: string;
|
|
10
|
+
languages: string[];
|
|
11
|
+
setLanguage: (language: string) => void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export declare const TranslatorProvider: ({ children, translations, defaultLanguage, persist, persistKey, autoDetectLanguage }: TranslatorProviderType) => JSX_2.Element;
|
|
15
|
+
|
|
16
|
+
declare type TranslatorProviderType = {
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
translations: Translation[];
|
|
19
|
+
defaultLanguage?: string;
|
|
20
|
+
persist?: boolean;
|
|
21
|
+
persistKey?: string;
|
|
22
|
+
autoDetectLanguage?: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export declare const useTranslator: () => TranslatorContextType;
|
|
26
|
+
|
|
27
|
+
export { }
|
|
@@ -0,0 +1,665 @@
|
|
|
1
|
+
import xe, { createContext as vr, useContext as dr, useState as pr, useEffect as gr } from "react";
|
|
2
|
+
var J = { exports: {} }, $ = {};
|
|
3
|
+
/**
|
|
4
|
+
* @license React
|
|
5
|
+
* react-jsx-runtime.production.min.js
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the MIT license found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/
|
|
12
|
+
var Oe;
|
|
13
|
+
function br() {
|
|
14
|
+
if (Oe) return $;
|
|
15
|
+
Oe = 1;
|
|
16
|
+
var p = xe, y = Symbol.for("react.element"), m = Symbol.for("react.fragment"), b = Object.prototype.hasOwnProperty, C = p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, j = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
17
|
+
function S(T, s, O) {
|
|
18
|
+
var v, E = {}, R = null, w = null;
|
|
19
|
+
O !== void 0 && (R = "" + O), s.key !== void 0 && (R = "" + s.key), s.ref !== void 0 && (w = s.ref);
|
|
20
|
+
for (v in s) b.call(s, v) && !j.hasOwnProperty(v) && (E[v] = s[v]);
|
|
21
|
+
if (T && T.defaultProps) for (v in s = T.defaultProps, s) E[v] === void 0 && (E[v] = s[v]);
|
|
22
|
+
return { $$typeof: y, type: T, key: R, ref: w, props: E, _owner: C.current };
|
|
23
|
+
}
|
|
24
|
+
return $.Fragment = m, $.jsx = S, $.jsxs = S, $;
|
|
25
|
+
}
|
|
26
|
+
var W = {};
|
|
27
|
+
/**
|
|
28
|
+
* @license React
|
|
29
|
+
* react-jsx-runtime.development.js
|
|
30
|
+
*
|
|
31
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
32
|
+
*
|
|
33
|
+
* This source code is licensed under the MIT license found in the
|
|
34
|
+
* LICENSE file in the root directory of this source tree.
|
|
35
|
+
*/
|
|
36
|
+
var Se;
|
|
37
|
+
function hr() {
|
|
38
|
+
return Se || (Se = 1, process.env.NODE_ENV !== "production" && function() {
|
|
39
|
+
var p = xe, y = Symbol.for("react.element"), m = Symbol.for("react.portal"), b = Symbol.for("react.fragment"), C = Symbol.for("react.strict_mode"), j = Symbol.for("react.profiler"), S = Symbol.for("react.provider"), T = Symbol.for("react.context"), s = Symbol.for("react.forward_ref"), O = Symbol.for("react.suspense"), v = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), R = Symbol.for("react.lazy"), w = Symbol.for("react.offscreen"), Y = Symbol.iterator, re = "@@iterator";
|
|
40
|
+
function q(e) {
|
|
41
|
+
if (e === null || typeof e != "object")
|
|
42
|
+
return null;
|
|
43
|
+
var r = Y && e[Y] || e[re];
|
|
44
|
+
return typeof r == "function" ? r : null;
|
|
45
|
+
}
|
|
46
|
+
var k = p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
47
|
+
function c(e) {
|
|
48
|
+
{
|
|
49
|
+
for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++)
|
|
50
|
+
t[n - 1] = arguments[n];
|
|
51
|
+
ke("error", e, t);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function ke(e, r, t) {
|
|
55
|
+
{
|
|
56
|
+
var n = k.ReactDebugCurrentFrame, i = n.getStackAddendum();
|
|
57
|
+
i !== "" && (r += "%s", t = t.concat([i]));
|
|
58
|
+
var u = t.map(function(o) {
|
|
59
|
+
return String(o);
|
|
60
|
+
});
|
|
61
|
+
u.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, u);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
var De = !1, Fe = !1, Ae = !1, Ie = !1, Le = !1, te;
|
|
65
|
+
te = Symbol.for("react.module.reference");
|
|
66
|
+
function $e(e) {
|
|
67
|
+
return !!(typeof e == "string" || typeof e == "function" || e === b || e === j || Le || e === C || e === O || e === v || Ie || e === w || De || Fe || Ae || typeof e == "object" && e !== null && (e.$$typeof === R || e.$$typeof === E || e.$$typeof === S || e.$$typeof === T || e.$$typeof === s || // This needs to include all possible module reference object
|
|
68
|
+
// types supported by any Flight configuration anywhere since
|
|
69
|
+
// we don't know which Flight build this will end up being used
|
|
70
|
+
// with.
|
|
71
|
+
e.$$typeof === te || e.getModuleId !== void 0));
|
|
72
|
+
}
|
|
73
|
+
function We(e, r, t) {
|
|
74
|
+
var n = e.displayName;
|
|
75
|
+
if (n)
|
|
76
|
+
return n;
|
|
77
|
+
var i = r.displayName || r.name || "";
|
|
78
|
+
return i !== "" ? t + "(" + i + ")" : t;
|
|
79
|
+
}
|
|
80
|
+
function ne(e) {
|
|
81
|
+
return e.displayName || "Context";
|
|
82
|
+
}
|
|
83
|
+
function _(e) {
|
|
84
|
+
if (e == null)
|
|
85
|
+
return null;
|
|
86
|
+
if (typeof e.tag == "number" && c("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
|
|
87
|
+
return e.displayName || e.name || null;
|
|
88
|
+
if (typeof e == "string")
|
|
89
|
+
return e;
|
|
90
|
+
switch (e) {
|
|
91
|
+
case b:
|
|
92
|
+
return "Fragment";
|
|
93
|
+
case m:
|
|
94
|
+
return "Portal";
|
|
95
|
+
case j:
|
|
96
|
+
return "Profiler";
|
|
97
|
+
case C:
|
|
98
|
+
return "StrictMode";
|
|
99
|
+
case O:
|
|
100
|
+
return "Suspense";
|
|
101
|
+
case v:
|
|
102
|
+
return "SuspenseList";
|
|
103
|
+
}
|
|
104
|
+
if (typeof e == "object")
|
|
105
|
+
switch (e.$$typeof) {
|
|
106
|
+
case T:
|
|
107
|
+
var r = e;
|
|
108
|
+
return ne(r) + ".Consumer";
|
|
109
|
+
case S:
|
|
110
|
+
var t = e;
|
|
111
|
+
return ne(t._context) + ".Provider";
|
|
112
|
+
case s:
|
|
113
|
+
return We(e, e.render, "ForwardRef");
|
|
114
|
+
case E:
|
|
115
|
+
var n = e.displayName || null;
|
|
116
|
+
return n !== null ? n : _(e.type) || "Memo";
|
|
117
|
+
case R: {
|
|
118
|
+
var i = e, u = i._payload, o = i._init;
|
|
119
|
+
try {
|
|
120
|
+
return _(o(u));
|
|
121
|
+
} catch {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
var P = Object.assign, A = 0, ae, oe, ie, ue, se, le, fe;
|
|
129
|
+
function ce() {
|
|
130
|
+
}
|
|
131
|
+
ce.__reactDisabledLog = !0;
|
|
132
|
+
function Ye() {
|
|
133
|
+
{
|
|
134
|
+
if (A === 0) {
|
|
135
|
+
ae = console.log, oe = console.info, ie = console.warn, ue = console.error, se = console.group, le = console.groupCollapsed, fe = console.groupEnd;
|
|
136
|
+
var e = {
|
|
137
|
+
configurable: !0,
|
|
138
|
+
enumerable: !0,
|
|
139
|
+
value: ce,
|
|
140
|
+
writable: !0
|
|
141
|
+
};
|
|
142
|
+
Object.defineProperties(console, {
|
|
143
|
+
info: e,
|
|
144
|
+
log: e,
|
|
145
|
+
warn: e,
|
|
146
|
+
error: e,
|
|
147
|
+
group: e,
|
|
148
|
+
groupCollapsed: e,
|
|
149
|
+
groupEnd: e
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
A++;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function Me() {
|
|
156
|
+
{
|
|
157
|
+
if (A--, A === 0) {
|
|
158
|
+
var e = {
|
|
159
|
+
configurable: !0,
|
|
160
|
+
enumerable: !0,
|
|
161
|
+
writable: !0
|
|
162
|
+
};
|
|
163
|
+
Object.defineProperties(console, {
|
|
164
|
+
log: P({}, e, {
|
|
165
|
+
value: ae
|
|
166
|
+
}),
|
|
167
|
+
info: P({}, e, {
|
|
168
|
+
value: oe
|
|
169
|
+
}),
|
|
170
|
+
warn: P({}, e, {
|
|
171
|
+
value: ie
|
|
172
|
+
}),
|
|
173
|
+
error: P({}, e, {
|
|
174
|
+
value: ue
|
|
175
|
+
}),
|
|
176
|
+
group: P({}, e, {
|
|
177
|
+
value: se
|
|
178
|
+
}),
|
|
179
|
+
groupCollapsed: P({}, e, {
|
|
180
|
+
value: le
|
|
181
|
+
}),
|
|
182
|
+
groupEnd: P({}, e, {
|
|
183
|
+
value: fe
|
|
184
|
+
})
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
A < 0 && c("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
var B = k.ReactCurrentDispatcher, G;
|
|
191
|
+
function M(e, r, t) {
|
|
192
|
+
{
|
|
193
|
+
if (G === void 0)
|
|
194
|
+
try {
|
|
195
|
+
throw Error();
|
|
196
|
+
} catch (i) {
|
|
197
|
+
var n = i.stack.trim().match(/\n( *(at )?)/);
|
|
198
|
+
G = n && n[1] || "";
|
|
199
|
+
}
|
|
200
|
+
return `
|
|
201
|
+
` + G + e;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
var K = !1, V;
|
|
205
|
+
{
|
|
206
|
+
var Ve = typeof WeakMap == "function" ? WeakMap : Map;
|
|
207
|
+
V = new Ve();
|
|
208
|
+
}
|
|
209
|
+
function ve(e, r) {
|
|
210
|
+
if (!e || K)
|
|
211
|
+
return "";
|
|
212
|
+
{
|
|
213
|
+
var t = V.get(e);
|
|
214
|
+
if (t !== void 0)
|
|
215
|
+
return t;
|
|
216
|
+
}
|
|
217
|
+
var n;
|
|
218
|
+
K = !0;
|
|
219
|
+
var i = Error.prepareStackTrace;
|
|
220
|
+
Error.prepareStackTrace = void 0;
|
|
221
|
+
var u;
|
|
222
|
+
u = B.current, B.current = null, Ye();
|
|
223
|
+
try {
|
|
224
|
+
if (r) {
|
|
225
|
+
var o = function() {
|
|
226
|
+
throw Error();
|
|
227
|
+
};
|
|
228
|
+
if (Object.defineProperty(o.prototype, "props", {
|
|
229
|
+
set: function() {
|
|
230
|
+
throw Error();
|
|
231
|
+
}
|
|
232
|
+
}), typeof Reflect == "object" && Reflect.construct) {
|
|
233
|
+
try {
|
|
234
|
+
Reflect.construct(o, []);
|
|
235
|
+
} catch (g) {
|
|
236
|
+
n = g;
|
|
237
|
+
}
|
|
238
|
+
Reflect.construct(e, [], o);
|
|
239
|
+
} else {
|
|
240
|
+
try {
|
|
241
|
+
o.call();
|
|
242
|
+
} catch (g) {
|
|
243
|
+
n = g;
|
|
244
|
+
}
|
|
245
|
+
e.call(o.prototype);
|
|
246
|
+
}
|
|
247
|
+
} else {
|
|
248
|
+
try {
|
|
249
|
+
throw Error();
|
|
250
|
+
} catch (g) {
|
|
251
|
+
n = g;
|
|
252
|
+
}
|
|
253
|
+
e();
|
|
254
|
+
}
|
|
255
|
+
} catch (g) {
|
|
256
|
+
if (g && n && typeof g.stack == "string") {
|
|
257
|
+
for (var a = g.stack.split(`
|
|
258
|
+
`), d = n.stack.split(`
|
|
259
|
+
`), l = a.length - 1, f = d.length - 1; l >= 1 && f >= 0 && a[l] !== d[f]; )
|
|
260
|
+
f--;
|
|
261
|
+
for (; l >= 1 && f >= 0; l--, f--)
|
|
262
|
+
if (a[l] !== d[f]) {
|
|
263
|
+
if (l !== 1 || f !== 1)
|
|
264
|
+
do
|
|
265
|
+
if (l--, f--, f < 0 || a[l] !== d[f]) {
|
|
266
|
+
var h = `
|
|
267
|
+
` + a[l].replace(" at new ", " at ");
|
|
268
|
+
return e.displayName && h.includes("<anonymous>") && (h = h.replace("<anonymous>", e.displayName)), typeof e == "function" && V.set(e, h), h;
|
|
269
|
+
}
|
|
270
|
+
while (l >= 1 && f >= 0);
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
} finally {
|
|
275
|
+
K = !1, B.current = u, Me(), Error.prepareStackTrace = i;
|
|
276
|
+
}
|
|
277
|
+
var F = e ? e.displayName || e.name : "", x = F ? M(F) : "";
|
|
278
|
+
return typeof e == "function" && V.set(e, x), x;
|
|
279
|
+
}
|
|
280
|
+
function Ue(e, r, t) {
|
|
281
|
+
return ve(e, !1);
|
|
282
|
+
}
|
|
283
|
+
function Ne(e) {
|
|
284
|
+
var r = e.prototype;
|
|
285
|
+
return !!(r && r.isReactComponent);
|
|
286
|
+
}
|
|
287
|
+
function U(e, r, t) {
|
|
288
|
+
if (e == null)
|
|
289
|
+
return "";
|
|
290
|
+
if (typeof e == "function")
|
|
291
|
+
return ve(e, Ne(e));
|
|
292
|
+
if (typeof e == "string")
|
|
293
|
+
return M(e);
|
|
294
|
+
switch (e) {
|
|
295
|
+
case O:
|
|
296
|
+
return M("Suspense");
|
|
297
|
+
case v:
|
|
298
|
+
return M("SuspenseList");
|
|
299
|
+
}
|
|
300
|
+
if (typeof e == "object")
|
|
301
|
+
switch (e.$$typeof) {
|
|
302
|
+
case s:
|
|
303
|
+
return Ue(e.render);
|
|
304
|
+
case E:
|
|
305
|
+
return U(e.type, r, t);
|
|
306
|
+
case R: {
|
|
307
|
+
var n = e, i = n._payload, u = n._init;
|
|
308
|
+
try {
|
|
309
|
+
return U(u(i), r, t);
|
|
310
|
+
} catch {
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return "";
|
|
315
|
+
}
|
|
316
|
+
var I = Object.prototype.hasOwnProperty, de = {}, pe = k.ReactDebugCurrentFrame;
|
|
317
|
+
function N(e) {
|
|
318
|
+
if (e) {
|
|
319
|
+
var r = e._owner, t = U(e.type, e._source, r ? r.type : null);
|
|
320
|
+
pe.setExtraStackFrame(t);
|
|
321
|
+
} else
|
|
322
|
+
pe.setExtraStackFrame(null);
|
|
323
|
+
}
|
|
324
|
+
function Je(e, r, t, n, i) {
|
|
325
|
+
{
|
|
326
|
+
var u = Function.call.bind(I);
|
|
327
|
+
for (var o in e)
|
|
328
|
+
if (u(e, o)) {
|
|
329
|
+
var a = void 0;
|
|
330
|
+
try {
|
|
331
|
+
if (typeof e[o] != "function") {
|
|
332
|
+
var d = Error((n || "React class") + ": " + t + " type `" + o + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[o] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
|
333
|
+
throw d.name = "Invariant Violation", d;
|
|
334
|
+
}
|
|
335
|
+
a = e[o](r, o, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
|
336
|
+
} catch (l) {
|
|
337
|
+
a = l;
|
|
338
|
+
}
|
|
339
|
+
a && !(a instanceof Error) && (N(i), c("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, o, typeof a), N(null)), a instanceof Error && !(a.message in de) && (de[a.message] = !0, N(i), c("Failed %s type: %s", t, a.message), N(null));
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
var qe = Array.isArray;
|
|
344
|
+
function z(e) {
|
|
345
|
+
return qe(e);
|
|
346
|
+
}
|
|
347
|
+
function Be(e) {
|
|
348
|
+
{
|
|
349
|
+
var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
350
|
+
return t;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
function Ge(e) {
|
|
354
|
+
try {
|
|
355
|
+
return ge(e), !1;
|
|
356
|
+
} catch {
|
|
357
|
+
return !0;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
function ge(e) {
|
|
361
|
+
return "" + e;
|
|
362
|
+
}
|
|
363
|
+
function be(e) {
|
|
364
|
+
if (Ge(e))
|
|
365
|
+
return c("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Be(e)), ge(e);
|
|
366
|
+
}
|
|
367
|
+
var L = k.ReactCurrentOwner, Ke = {
|
|
368
|
+
key: !0,
|
|
369
|
+
ref: !0,
|
|
370
|
+
__self: !0,
|
|
371
|
+
__source: !0
|
|
372
|
+
}, he, ye, X;
|
|
373
|
+
X = {};
|
|
374
|
+
function ze(e) {
|
|
375
|
+
if (I.call(e, "ref")) {
|
|
376
|
+
var r = Object.getOwnPropertyDescriptor(e, "ref").get;
|
|
377
|
+
if (r && r.isReactWarning)
|
|
378
|
+
return !1;
|
|
379
|
+
}
|
|
380
|
+
return e.ref !== void 0;
|
|
381
|
+
}
|
|
382
|
+
function Xe(e) {
|
|
383
|
+
if (I.call(e, "key")) {
|
|
384
|
+
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
385
|
+
if (r && r.isReactWarning)
|
|
386
|
+
return !1;
|
|
387
|
+
}
|
|
388
|
+
return e.key !== void 0;
|
|
389
|
+
}
|
|
390
|
+
function He(e, r) {
|
|
391
|
+
if (typeof e.ref == "string" && L.current && r && L.current.stateNode !== r) {
|
|
392
|
+
var t = _(L.current.type);
|
|
393
|
+
X[t] || (c('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', _(L.current.type), e.ref), X[t] = !0);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
function Ze(e, r) {
|
|
397
|
+
{
|
|
398
|
+
var t = function() {
|
|
399
|
+
he || (he = !0, c("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
|
|
400
|
+
};
|
|
401
|
+
t.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
402
|
+
get: t,
|
|
403
|
+
configurable: !0
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
function Qe(e, r) {
|
|
408
|
+
{
|
|
409
|
+
var t = function() {
|
|
410
|
+
ye || (ye = !0, c("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
|
|
411
|
+
};
|
|
412
|
+
t.isReactWarning = !0, Object.defineProperty(e, "ref", {
|
|
413
|
+
get: t,
|
|
414
|
+
configurable: !0
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
var er = function(e, r, t, n, i, u, o) {
|
|
419
|
+
var a = {
|
|
420
|
+
// This tag allows us to uniquely identify this as a React Element
|
|
421
|
+
$$typeof: y,
|
|
422
|
+
// Built-in properties that belong on the element
|
|
423
|
+
type: e,
|
|
424
|
+
key: r,
|
|
425
|
+
ref: t,
|
|
426
|
+
props: o,
|
|
427
|
+
// Record the component responsible for creating this element.
|
|
428
|
+
_owner: u
|
|
429
|
+
};
|
|
430
|
+
return a._store = {}, Object.defineProperty(a._store, "validated", {
|
|
431
|
+
configurable: !1,
|
|
432
|
+
enumerable: !1,
|
|
433
|
+
writable: !0,
|
|
434
|
+
value: !1
|
|
435
|
+
}), Object.defineProperty(a, "_self", {
|
|
436
|
+
configurable: !1,
|
|
437
|
+
enumerable: !1,
|
|
438
|
+
writable: !1,
|
|
439
|
+
value: n
|
|
440
|
+
}), Object.defineProperty(a, "_source", {
|
|
441
|
+
configurable: !1,
|
|
442
|
+
enumerable: !1,
|
|
443
|
+
writable: !1,
|
|
444
|
+
value: i
|
|
445
|
+
}), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
|
|
446
|
+
};
|
|
447
|
+
function rr(e, r, t, n, i) {
|
|
448
|
+
{
|
|
449
|
+
var u, o = {}, a = null, d = null;
|
|
450
|
+
t !== void 0 && (be(t), a = "" + t), Xe(r) && (be(r.key), a = "" + r.key), ze(r) && (d = r.ref, He(r, i));
|
|
451
|
+
for (u in r)
|
|
452
|
+
I.call(r, u) && !Ke.hasOwnProperty(u) && (o[u] = r[u]);
|
|
453
|
+
if (e && e.defaultProps) {
|
|
454
|
+
var l = e.defaultProps;
|
|
455
|
+
for (u in l)
|
|
456
|
+
o[u] === void 0 && (o[u] = l[u]);
|
|
457
|
+
}
|
|
458
|
+
if (a || d) {
|
|
459
|
+
var f = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
|
|
460
|
+
a && Ze(o, f), d && Qe(o, f);
|
|
461
|
+
}
|
|
462
|
+
return er(e, a, d, i, n, L.current, o);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
var H = k.ReactCurrentOwner, Ee = k.ReactDebugCurrentFrame;
|
|
466
|
+
function D(e) {
|
|
467
|
+
if (e) {
|
|
468
|
+
var r = e._owner, t = U(e.type, e._source, r ? r.type : null);
|
|
469
|
+
Ee.setExtraStackFrame(t);
|
|
470
|
+
} else
|
|
471
|
+
Ee.setExtraStackFrame(null);
|
|
472
|
+
}
|
|
473
|
+
var Z;
|
|
474
|
+
Z = !1;
|
|
475
|
+
function Q(e) {
|
|
476
|
+
return typeof e == "object" && e !== null && e.$$typeof === y;
|
|
477
|
+
}
|
|
478
|
+
function Re() {
|
|
479
|
+
{
|
|
480
|
+
if (H.current) {
|
|
481
|
+
var e = _(H.current.type);
|
|
482
|
+
if (e)
|
|
483
|
+
return `
|
|
484
|
+
|
|
485
|
+
Check the render method of \`` + e + "`.";
|
|
486
|
+
}
|
|
487
|
+
return "";
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
function tr(e) {
|
|
491
|
+
return "";
|
|
492
|
+
}
|
|
493
|
+
var _e = {};
|
|
494
|
+
function nr(e) {
|
|
495
|
+
{
|
|
496
|
+
var r = Re();
|
|
497
|
+
if (!r) {
|
|
498
|
+
var t = typeof e == "string" ? e : e.displayName || e.name;
|
|
499
|
+
t && (r = `
|
|
500
|
+
|
|
501
|
+
Check the top-level render call using <` + t + ">.");
|
|
502
|
+
}
|
|
503
|
+
return r;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
function me(e, r) {
|
|
507
|
+
{
|
|
508
|
+
if (!e._store || e._store.validated || e.key != null)
|
|
509
|
+
return;
|
|
510
|
+
e._store.validated = !0;
|
|
511
|
+
var t = nr(r);
|
|
512
|
+
if (_e[t])
|
|
513
|
+
return;
|
|
514
|
+
_e[t] = !0;
|
|
515
|
+
var n = "";
|
|
516
|
+
e && e._owner && e._owner !== H.current && (n = " It was passed a child from " + _(e._owner.type) + "."), D(e), c('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), D(null);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
function Te(e, r) {
|
|
520
|
+
{
|
|
521
|
+
if (typeof e != "object")
|
|
522
|
+
return;
|
|
523
|
+
if (z(e))
|
|
524
|
+
for (var t = 0; t < e.length; t++) {
|
|
525
|
+
var n = e[t];
|
|
526
|
+
Q(n) && me(n, r);
|
|
527
|
+
}
|
|
528
|
+
else if (Q(e))
|
|
529
|
+
e._store && (e._store.validated = !0);
|
|
530
|
+
else if (e) {
|
|
531
|
+
var i = q(e);
|
|
532
|
+
if (typeof i == "function" && i !== e.entries)
|
|
533
|
+
for (var u = i.call(e), o; !(o = u.next()).done; )
|
|
534
|
+
Q(o.value) && me(o.value, r);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
function ar(e) {
|
|
539
|
+
{
|
|
540
|
+
var r = e.type;
|
|
541
|
+
if (r == null || typeof r == "string")
|
|
542
|
+
return;
|
|
543
|
+
var t;
|
|
544
|
+
if (typeof r == "function")
|
|
545
|
+
t = r.propTypes;
|
|
546
|
+
else if (typeof r == "object" && (r.$$typeof === s || // Note: Memo only checks outer props here.
|
|
547
|
+
// Inner props are checked in the reconciler.
|
|
548
|
+
r.$$typeof === E))
|
|
549
|
+
t = r.propTypes;
|
|
550
|
+
else
|
|
551
|
+
return;
|
|
552
|
+
if (t) {
|
|
553
|
+
var n = _(r);
|
|
554
|
+
Je(t, e.props, "prop", n, e);
|
|
555
|
+
} else if (r.PropTypes !== void 0 && !Z) {
|
|
556
|
+
Z = !0;
|
|
557
|
+
var i = _(r);
|
|
558
|
+
c("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", i || "Unknown");
|
|
559
|
+
}
|
|
560
|
+
typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && c("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
function or(e) {
|
|
564
|
+
{
|
|
565
|
+
for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
|
|
566
|
+
var n = r[t];
|
|
567
|
+
if (n !== "children" && n !== "key") {
|
|
568
|
+
D(e), c("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), D(null);
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
e.ref !== null && (D(e), c("Invalid attribute `ref` supplied to `React.Fragment`."), D(null));
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
var we = {};
|
|
576
|
+
function Ce(e, r, t, n, i, u) {
|
|
577
|
+
{
|
|
578
|
+
var o = $e(e);
|
|
579
|
+
if (!o) {
|
|
580
|
+
var a = "";
|
|
581
|
+
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (a += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
|
|
582
|
+
var d = tr();
|
|
583
|
+
d ? a += d : a += Re();
|
|
584
|
+
var l;
|
|
585
|
+
e === null ? l = "null" : z(e) ? l = "array" : e !== void 0 && e.$$typeof === y ? (l = "<" + (_(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : l = typeof e, c("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", l, a);
|
|
586
|
+
}
|
|
587
|
+
var f = rr(e, r, t, i, u);
|
|
588
|
+
if (f == null)
|
|
589
|
+
return f;
|
|
590
|
+
if (o) {
|
|
591
|
+
var h = r.children;
|
|
592
|
+
if (h !== void 0)
|
|
593
|
+
if (n)
|
|
594
|
+
if (z(h)) {
|
|
595
|
+
for (var F = 0; F < h.length; F++)
|
|
596
|
+
Te(h[F], e);
|
|
597
|
+
Object.freeze && Object.freeze(h);
|
|
598
|
+
} else
|
|
599
|
+
c("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
600
|
+
else
|
|
601
|
+
Te(h, e);
|
|
602
|
+
}
|
|
603
|
+
if (I.call(r, "key")) {
|
|
604
|
+
var x = _(e), g = Object.keys(r).filter(function(cr) {
|
|
605
|
+
return cr !== "key";
|
|
606
|
+
}), ee = g.length > 0 ? "{key: someKey, " + g.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
607
|
+
if (!we[x + ee]) {
|
|
608
|
+
var fr = g.length > 0 ? "{" + g.join(": ..., ") + ": ...}" : "{}";
|
|
609
|
+
c(`A props object containing a "key" prop is being spread into JSX:
|
|
610
|
+
let props = %s;
|
|
611
|
+
<%s {...props} />
|
|
612
|
+
React keys must be passed directly to JSX without using spread:
|
|
613
|
+
let props = %s;
|
|
614
|
+
<%s key={someKey} {...props} />`, ee, x, fr, x), we[x + ee] = !0;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
return e === b ? or(f) : ar(f), f;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
function ir(e, r, t) {
|
|
621
|
+
return Ce(e, r, t, !0);
|
|
622
|
+
}
|
|
623
|
+
function ur(e, r, t) {
|
|
624
|
+
return Ce(e, r, t, !1);
|
|
625
|
+
}
|
|
626
|
+
var sr = ur, lr = ir;
|
|
627
|
+
W.Fragment = b, W.jsx = sr, W.jsxs = lr;
|
|
628
|
+
}()), W;
|
|
629
|
+
}
|
|
630
|
+
var Pe;
|
|
631
|
+
function yr() {
|
|
632
|
+
return Pe || (Pe = 1, process.env.NODE_ENV === "production" ? J.exports = br() : J.exports = hr()), J.exports;
|
|
633
|
+
}
|
|
634
|
+
var Er = yr();
|
|
635
|
+
const je = vr(null), Rr = () => {
|
|
636
|
+
const p = dr(je);
|
|
637
|
+
if (!p) throw new Error("useTranslatorContext must be used within a TranslatorProvider");
|
|
638
|
+
return p;
|
|
639
|
+
}, _r = (p) => {
|
|
640
|
+
var m, b;
|
|
641
|
+
return ((b = (m = navigator == null ? void 0 : navigator.language) == null ? void 0 : m.split("-")) == null ? void 0 : b[0]) || p;
|
|
642
|
+
}, mr = (p) => localStorage.getItem(p), Tr = (p, y) => {
|
|
643
|
+
localStorage.setItem(p, y);
|
|
644
|
+
}, Cr = ({
|
|
645
|
+
children: p,
|
|
646
|
+
translations: y,
|
|
647
|
+
defaultLanguage: m = "en",
|
|
648
|
+
persist: b = !1,
|
|
649
|
+
persistKey: C = "language",
|
|
650
|
+
autoDetectLanguage: j = !1
|
|
651
|
+
}) => {
|
|
652
|
+
const S = b ? mr(C) : void 0, T = j && !S ? _r(m) : m, [s, O] = pr(T);
|
|
653
|
+
gr(() => {
|
|
654
|
+
b && Tr(C, s);
|
|
655
|
+
}, [s, b, C]);
|
|
656
|
+
const v = Object.keys(y[0] || {}), E = (R) => {
|
|
657
|
+
const w = y.find((Y) => Object.values(Y).some((q) => q.toLocaleLowerCase() === R.toLocaleLowerCase()));
|
|
658
|
+
return w != null && w[s] ? w[s] : (console.warn(`[Translator Debug] Missing translation "${s}" for: '${R}'`), R);
|
|
659
|
+
};
|
|
660
|
+
return /* @__PURE__ */ Er.jsx(je.Provider, { value: { t: E, language: s, languages: v, setLanguage: O }, children: p });
|
|
661
|
+
}, Or = () => Rr();
|
|
662
|
+
export {
|
|
663
|
+
Cr as TranslatorProvider,
|
|
664
|
+
Or as useTranslator
|
|
665
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
(function(w,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],m):(w=typeof globalThis<"u"?globalThis:w||self,m(w["vbss/translator"]={},w.React))})(this,function(w,m){"use strict";var U={exports:{}},L={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var ne;function De(){if(ne)return L;ne=1;var p=m,h=Symbol.for("react.element"),T=Symbol.for("react.fragment"),b=Object.prototype.hasOwnProperty,C=p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,D={key:!0,ref:!0,__self:!0,__source:!0};function j(O,s,P){var d,R={},E=null,S=null;P!==void 0&&(E=""+P),s.key!==void 0&&(E=""+s.key),s.ref!==void 0&&(S=s.ref);for(d in s)b.call(s,d)&&!D.hasOwnProperty(d)&&(R[d]=s[d]);if(O&&O.defaultProps)for(d in s=O.defaultProps,s)R[d]===void 0&&(R[d]=s[d]);return{$$typeof:h,type:O,key:E,ref:S,props:R,_owner:C.current}}return L.Fragment=T,L.jsx=j,L.jsxs=j,L}var W={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var ae;function Fe(){return ae||(ae=1,process.env.NODE_ENV!=="production"&&function(){var p=m,h=Symbol.for("react.element"),T=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),D=Symbol.for("react.profiler"),j=Symbol.for("react.provider"),O=Symbol.for("react.context"),s=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),S=Symbol.for("react.offscreen"),$=Symbol.iterator,ue="@@iterator";function K(e){if(e===null||typeof e!="object")return null;var r=$&&e[$]||e[ue];return typeof r=="function"?r:null}var F=p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function c(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];$e("error",e,t)}}function $e(e,r,t){{var n=F.ReactDebugCurrentFrame,i=n.getStackAddendum();i!==""&&(r+="%s",t=t.concat([i]));var u=t.map(function(o){return String(o)});u.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,u)}}var Ne=!1,Je=!1,Be=!1,Ge=!1,Ke=!1,se;se=Symbol.for("react.module.reference");function qe(e){return!!(typeof e=="string"||typeof e=="function"||e===b||e===D||Ke||e===C||e===P||e===d||Ge||e===S||Ne||Je||Be||typeof e=="object"&&e!==null&&(e.$$typeof===E||e.$$typeof===R||e.$$typeof===j||e.$$typeof===O||e.$$typeof===s||e.$$typeof===se||e.getModuleId!==void 0))}function ze(e,r,t){var n=e.displayName;if(n)return n;var i=r.displayName||r.name||"";return i!==""?t+"("+i+")":t}function le(e){return e.displayName||"Context"}function _(e){if(e==null)return null;if(typeof e.tag=="number"&&c("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case b:return"Fragment";case T:return"Portal";case D:return"Profiler";case C:return"StrictMode";case P:return"Suspense";case d:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case O:var r=e;return le(r)+".Consumer";case j:var t=e;return le(t._context)+".Provider";case s:return ze(e,e.render,"ForwardRef");case R:var n=e.displayName||null;return n!==null?n:_(e.type)||"Memo";case E:{var i=e,u=i._payload,o=i._init;try{return _(o(u))}catch{return null}}}return null}var x=Object.assign,Y=0,fe,ce,de,ve,pe,ge,be;function ye(){}ye.__reactDisabledLog=!0;function Xe(){{if(Y===0){fe=console.log,ce=console.info,de=console.warn,ve=console.error,pe=console.group,ge=console.groupCollapsed,be=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ye,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}Y++}}function He(){{if(Y--,Y===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:x({},e,{value:fe}),info:x({},e,{value:ce}),warn:x({},e,{value:de}),error:x({},e,{value:ve}),group:x({},e,{value:pe}),groupCollapsed:x({},e,{value:ge}),groupEnd:x({},e,{value:be})})}Y<0&&c("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var q=F.ReactCurrentDispatcher,z;function N(e,r,t){{if(z===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);z=n&&n[1]||""}return`
|
|
18
|
+
`+z+e}}var X=!1,J;{var Ze=typeof WeakMap=="function"?WeakMap:Map;J=new Ze}function he(e,r){if(!e||X)return"";{var t=J.get(e);if(t!==void 0)return t}var n;X=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=q.current,q.current=null,Xe();try{if(r){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(g){n=g}Reflect.construct(e,[],o)}else{try{o.call()}catch(g){n=g}e.call(o.prototype)}}else{try{throw Error()}catch(g){n=g}e()}}catch(g){if(g&&n&&typeof g.stack=="string"){for(var a=g.stack.split(`
|
|
19
|
+
`),v=n.stack.split(`
|
|
20
|
+
`),l=a.length-1,f=v.length-1;l>=1&&f>=0&&a[l]!==v[f];)f--;for(;l>=1&&f>=0;l--,f--)if(a[l]!==v[f]){if(l!==1||f!==1)do if(l--,f--,f<0||a[l]!==v[f]){var y=`
|
|
21
|
+
`+a[l].replace(" at new "," at ");return e.displayName&&y.includes("<anonymous>")&&(y=y.replace("<anonymous>",e.displayName)),typeof e=="function"&&J.set(e,y),y}while(l>=1&&f>=0);break}}}finally{X=!1,q.current=u,He(),Error.prepareStackTrace=i}var I=e?e.displayName||e.name:"",k=I?N(I):"";return typeof e=="function"&&J.set(e,k),k}function Qe(e,r,t){return he(e,!1)}function er(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function B(e,r,t){if(e==null)return"";if(typeof e=="function")return he(e,er(e));if(typeof e=="string")return N(e);switch(e){case P:return N("Suspense");case d:return N("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case s:return Qe(e.render);case R:return B(e.type,r,t);case E:{var n=e,i=n._payload,u=n._init;try{return B(u(i),r,t)}catch{}}}return""}var M=Object.prototype.hasOwnProperty,Re={},Ee=F.ReactDebugCurrentFrame;function G(e){if(e){var r=e._owner,t=B(e.type,e._source,r?r.type:null);Ee.setExtraStackFrame(t)}else Ee.setExtraStackFrame(null)}function rr(e,r,t,n,i){{var u=Function.call.bind(M);for(var o in e)if(u(e,o)){var a=void 0;try{if(typeof e[o]!="function"){var v=Error((n||"React class")+": "+t+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}a=e[o](r,o,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(l){a=l}a&&!(a instanceof Error)&&(G(i),c("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,o,typeof a),G(null)),a instanceof Error&&!(a.message in Re)&&(Re[a.message]=!0,G(i),c("Failed %s type: %s",t,a.message),G(null))}}}var tr=Array.isArray;function H(e){return tr(e)}function nr(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function ar(e){try{return me(e),!1}catch{return!0}}function me(e){return""+e}function _e(e){if(ar(e))return c("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",nr(e)),me(e)}var V=F.ReactCurrentOwner,or={key:!0,ref:!0,__self:!0,__source:!0},Te,Oe,Z;Z={};function ir(e){if(M.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function ur(e){if(M.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function sr(e,r){if(typeof e.ref=="string"&&V.current&&r&&V.current.stateNode!==r){var t=_(V.current.type);Z[t]||(c('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',_(V.current.type),e.ref),Z[t]=!0)}}function lr(e,r){{var t=function(){Te||(Te=!0,c("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function fr(e,r){{var t=function(){Oe||(Oe=!0,c("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var cr=function(e,r,t,n,i,u,o){var a={$$typeof:h,type:e,key:r,ref:t,props:o,_owner:u};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function dr(e,r,t,n,i){{var u,o={},a=null,v=null;t!==void 0&&(_e(t),a=""+t),ur(r)&&(_e(r.key),a=""+r.key),ir(r)&&(v=r.ref,sr(r,i));for(u in r)M.call(r,u)&&!or.hasOwnProperty(u)&&(o[u]=r[u]);if(e&&e.defaultProps){var l=e.defaultProps;for(u in l)o[u]===void 0&&(o[u]=l[u])}if(a||v){var f=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&lr(o,f),v&&fr(o,f)}return cr(e,a,v,i,n,V.current,o)}}var Q=F.ReactCurrentOwner,Se=F.ReactDebugCurrentFrame;function A(e){if(e){var r=e._owner,t=B(e.type,e._source,r?r.type:null);Se.setExtraStackFrame(t)}else Se.setExtraStackFrame(null)}var ee;ee=!1;function re(e){return typeof e=="object"&&e!==null&&e.$$typeof===h}function we(){{if(Q.current){var e=_(Q.current.type);if(e)return`
|
|
22
|
+
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function vr(e){return""}var Ce={};function pr(e){{var r=we();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
|
|
24
|
+
|
|
25
|
+
Check the top-level render call using <`+t+">.")}return r}}function Pe(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=pr(r);if(Ce[t])return;Ce[t]=!0;var n="";e&&e._owner&&e._owner!==Q.current&&(n=" It was passed a child from "+_(e._owner.type)+"."),A(e),c('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),A(null)}}function je(e,r){{if(typeof e!="object")return;if(H(e))for(var t=0;t<e.length;t++){var n=e[t];re(n)&&Pe(n,r)}else if(re(e))e._store&&(e._store.validated=!0);else if(e){var i=K(e);if(typeof i=="function"&&i!==e.entries)for(var u=i.call(e),o;!(o=u.next()).done;)re(o.value)&&Pe(o.value,r)}}}function gr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===s||r.$$typeof===R))t=r.propTypes;else return;if(t){var n=_(r);rr(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!ee){ee=!0;var i=_(r);c("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",i||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&c("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function br(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){A(e),c("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),A(null);break}}e.ref!==null&&(A(e),c("Invalid attribute `ref` supplied to `React.Fragment`."),A(null))}}var xe={};function ke(e,r,t,n,i,u){{var o=qe(e);if(!o){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var v=vr();v?a+=v:a+=we();var l;e===null?l="null":H(e)?l="array":e!==void 0&&e.$$typeof===h?(l="<"+(_(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):l=typeof e,c("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",l,a)}var f=dr(e,r,t,i,u);if(f==null)return f;if(o){var y=r.children;if(y!==void 0)if(n)if(H(y)){for(var I=0;I<y.length;I++)je(y[I],e);Object.freeze&&Object.freeze(y)}else c("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else je(y,e)}if(M.call(r,"key")){var k=_(e),g=Object.keys(r).filter(function(_r){return _r!=="key"}),te=g.length>0?"{key: someKey, "+g.join(": ..., ")+": ...}":"{key: someKey}";if(!xe[k+te]){var mr=g.length>0?"{"+g.join(": ..., ")+": ...}":"{}";c(`A props object containing a "key" prop is being spread into JSX:
|
|
26
|
+
let props = %s;
|
|
27
|
+
<%s {...props} />
|
|
28
|
+
React keys must be passed directly to JSX without using spread:
|
|
29
|
+
let props = %s;
|
|
30
|
+
<%s key={someKey} {...props} />`,te,k,mr,k),xe[k+te]=!0}}return e===b?br(f):gr(f),f}}function yr(e,r,t){return ke(e,r,t,!0)}function hr(e,r,t){return ke(e,r,t,!1)}var Rr=hr,Er=yr;W.Fragment=b,W.jsx=Rr,W.jsxs=Er}()),W}var oe;function Ae(){return oe||(oe=1,process.env.NODE_ENV==="production"?U.exports=De():U.exports=Fe()),U.exports}var Ie=Ae();const ie=m.createContext(null),Le=()=>{const p=m.useContext(ie);if(!p)throw new Error("useTranslatorContext must be used within a TranslatorProvider");return p},We=p=>{var T,b;return((b=(T=navigator==null?void 0:navigator.language)==null?void 0:T.split("-"))==null?void 0:b[0])||p},Ye=p=>localStorage.getItem(p),Me=(p,h)=>{localStorage.setItem(p,h)},Ve=({children:p,translations:h,defaultLanguage:T="en",persist:b=!1,persistKey:C="language",autoDetectLanguage:D=!1})=>{const j=b?Ye(C):void 0,O=D&&!j?We(T):T,[s,P]=m.useState(O);m.useEffect(()=>{b&&Me(C,s)},[s,b,C]);const d=Object.keys(h[0]||{}),R=E=>{const S=h.find($=>Object.values($).some(K=>K.toLocaleLowerCase()===E.toLocaleLowerCase()));return S!=null&&S[s]?S[s]:(console.warn(`[Translator Debug] Missing translation "${s}" for: '${E}'`),E)};return Ie.jsx(ie.Provider,{value:{t:R,language:s,languages:d,setLanguage:P},children:p})},Ue=()=>Le();w.TranslatorProvider=Ve,w.useTranslator=Ue,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vbss-translator",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"main": "dist/vbss-translator-umd.cjs",
|
|
11
|
+
"module": "dist/vbss-translator.js",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/vbss-translator.d.ts",
|
|
15
|
+
"import": "./dist/vbss-translator.js",
|
|
16
|
+
"require": "./dist/vbss-translator-umd.cjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"types": "./dist/vbss-translator.d.ts",
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/vbss-io/vbss-translator.git"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"dev": "vite",
|
|
27
|
+
"build": "tsc && vite build",
|
|
28
|
+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
29
|
+
"patch-deploy": "npm version patch && npm publish",
|
|
30
|
+
"minor-deploy": "npm version minor && npm publish",
|
|
31
|
+
"major-deploy": "npm version major && npm publish"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"react": "^18.3.1",
|
|
35
|
+
"react-dom": "^18.3.1"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@eslint/js": "^9.15.0",
|
|
39
|
+
"@types/node": "^22.10.2",
|
|
40
|
+
"@types/react": "^18.3.12",
|
|
41
|
+
"@types/react-dom": "^18.3.1",
|
|
42
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
43
|
+
"eslint": "^9.15.0",
|
|
44
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
45
|
+
"eslint-plugin-react-refresh": "^0.4.14",
|
|
46
|
+
"globals": "^15.12.0",
|
|
47
|
+
"typescript": "~5.6.2",
|
|
48
|
+
"typescript-eslint": "^8.15.0",
|
|
49
|
+
"vite": "^6.0.1",
|
|
50
|
+
"vite-plugin-dts": "^4.3.0",
|
|
51
|
+
"vite-tsconfig-paths": "^5.1.4"
|
|
52
|
+
}
|
|
53
|
+
}
|