@tolgee/react 4.10.0-rc.f068ae1.0 → 5.0.0-alpha.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.
Files changed (40) hide show
  1. package/README.md +138 -27
  2. package/README.njk.md +84 -0
  3. package/dist/T.d.ts +3 -2
  4. package/dist/TolgeeProvider.d.ts +1 -0
  5. package/dist/hooks.d.ts +4 -1
  6. package/dist/index.d.ts +1 -1
  7. package/dist/tagsTools.d.ts +2 -1
  8. package/dist/tolgee-react.cjs.js +36 -53
  9. package/dist/tolgee-react.cjs.js.map +1 -1
  10. package/dist/tolgee-react.cjs.min.js +1 -1
  11. package/dist/tolgee-react.cjs.min.js.map +1 -1
  12. package/dist/{tolgee-react.esm.mjs → tolgee-react.esm.js} +38 -55
  13. package/dist/tolgee-react.esm.js.map +1 -0
  14. package/dist/tolgee-react.esm.min.mjs +1 -1
  15. package/dist/tolgee-react.esm.min.mjs.map +1 -1
  16. package/dist/tolgee-react.umd.js +36 -53
  17. package/dist/tolgee-react.umd.js.map +1 -1
  18. package/dist/tolgee-react.umd.min.js +1 -1
  19. package/dist/tolgee-react.umd.min.js.map +1 -1
  20. package/dist/useTranslateInternal.d.ts +2 -2
  21. package/lib/T.d.ts +3 -2
  22. package/lib/TolgeeProvider.d.ts +1 -0
  23. package/lib/hooks.d.ts +4 -1
  24. package/lib/index.d.ts +1 -1
  25. package/lib/tagsTools.d.ts +2 -1
  26. package/lib/useTranslateInternal.d.ts +2 -2
  27. package/package.json +10 -6
  28. package/dist/ReactPlugin.d.ts +0 -6
  29. package/dist/TolgeeProvider.spec.d.ts +0 -1
  30. package/dist/__integration/T.spec.d.ts +0 -1
  31. package/dist/__integration/TolgeeProvider.spec.d.ts +0 -6
  32. package/dist/__integration/mockTranslations.d.ts +0 -23
  33. package/dist/__integration/namespaces.spec.d.ts +0 -1
  34. package/dist/__integration/testConfig.d.ts +0 -9
  35. package/dist/__integration/tools.d.ts +0 -1
  36. package/dist/__integration/useTolgee.spec.d.ts +0 -1
  37. package/dist/__integration/useTranslation.spec.d.ts +0 -1
  38. package/dist/tolgee-react.esm.mjs.map +0 -1
  39. package/index.js +0 -7
  40. package/lib/ReactPlugin.d.ts +0 -6
package/README.md CHANGED
@@ -1,44 +1,90 @@
1
+ <!-- This file was generated using pnpm generate-readmes script
2
+
3
+ Don't edit this file. Edit the README.md.njk. Macros can be found in readmeMacros/macros.njk
4
+
5
+ -->
6
+
7
+ <h1 align="center" style="border-bottom: none">
8
+ <b>
9
+ <a href="https://tolgee.io">Tolgee for React</a><br>
10
+ </b>
11
+ The Tolgee i18n SDK for React
12
+ <br>
13
+ </h1>
14
+
15
+ <div align="center">
16
+
17
+ [![Logo](https://user-images.githubusercontent.com/18496315/188628892-33fcc282-26f1-4035-8105-95952bd93de9.svg)](https://tolgee.io)
18
+
19
+ Tolgee is an open-source alternative to Crowdin, Phrase, or Lokalise with its very own revolutionary integrations.
20
+
1
21
  ![test workflow](https://github.com/tolgee/tolgee-js/actions/workflows/test.yml/badge.svg)
2
- ![@tolgee/react version](https://img.shields.io/npm/v/@tolgee/react?label=%40tolgee%2Freact)
22
+
23
+ ![@tolgee/react version](https://img.shields.io/npm/v/@tolgee/react?label=@tolgee/react)
24
+
3
25
  ![types typescript](https://img.shields.io/badge/Types-Typescript-blue)
26
+ ![typescript](https://img.shields.io/github/languages/top/tolgee/tolgee-js)
4
27
  ![licence](https://img.shields.io/github/license/tolgee/tolgee-js)
5
- [![twitter](https://img.shields.io/twitter/follow/Tolgee_i18n?style=social)](https://twitter.com/Tolgee_i18n)
6
- [![github stars](https://img.shields.io/github/stars/tolgee/tolgee-js?style=social)](https://github.com/tolgee/tolgee-js)
28
+ [![github stars](https://img.shields.io/github/stars/tolgee/tolgee-js?style=social&label=Tolgee%20JS)](https://github.com/tolgee/tolgee-js)
29
+ [![github stars](https://img.shields.io/github/stars/tolgee/server?style=social&label=Tolgee%20Server)](https://github.com/tolgee/server)
30
+ [![Github discussions](https://img.shields.io/github/discussions/tolgee/tolgee-platform)](https://github.com/tolgee/tolgee-platform/discussions)
31
+ </div>
7
32
 
8
- # Tolgee for React
33
+ <div align="center">
9
34
 
10
- React integration library of Tolgee. For more information about using Tolgee with React, visit our
11
- [documentation website 📖](https://tolgee.io/docs/web/using_with_react/installation).
35
+ [<img src="https://img.shields.io/badge/-Facebook-424549?style=social&logo=facebook" height=25 />](https://www.facebook.com/Tolgee.i18n)
36
+ [<img src="https://img.shields.io/badge/-Twitter-424549?style=social&logo=twitter" height=25 />](https://twitter.com/Tolgee_i18n)
37
+ [<img src="https://img.shields.io/badge/-Linkedin-424549?style=social&logo=linkedin" height=25 />](https://www.linkedin.com/company/tolgee)
12
38
 
13
- [<img src="https://raw.githubusercontent.com/tolgee/documentation/main/tolgee_logo_text.svg" alt="Tolgee" width="200" />](https://tolgee.io)
39
+ **Become part of the family. Join [slack channel <img src="https://img.shields.io/badge/-Tolgee Comunity-424549?style=social&logo=slack" height=25 />](https://join.slack.com/t/tolgeecommunity/shared_invite/zt-195isb5u8-_RcSRgVJfvgsPpOBIok~IQ)**
14
40
 
15
- Lokalize (translate) your CRA, Gatsby, Next.js or other React projects to multiple languages with Tolgee. Integration of
16
- Tolgee is extremely simple! 🇯🇵 🇰🇷 🇩🇪 🇨🇳 🇺🇸 🇫🇷 🇪🇸 🇮🇹 🇷🇺 🇬🇧
41
+ </div>
17
42
 
18
- ## Features
19
43
 
20
- - All in One localization solution for your JS application 🙌
21
- - Out of box in-context localization 🎉
22
- - Automated screenshot generation 📷
23
- - Translation management platform 🎈
24
- - Open-source 🔥
44
+
45
+ # What is Tolgee for React?
46
+ React integration library of Tolgee. This package makes it super simple to add i18n to your React app!
47
+ For more information about using Tolgee with React, visit the [docs 📖](https://tolgee.io/integrations/react).
48
+
49
+ Localize (translate) your CRA, Gatsby, Next.js, or other React projects to multiple languages with Tolgee. Integration of Tolgee is extremely simple! 🇯🇵 🇰🇷 🇩🇪 🇨🇳 🇺🇸 🇫🇷 🇪🇸 🇮🇹 🇷🇺 🇬🇧
50
+
51
+
52
+ ## Quick links
53
+ - [Tolgee for React docs](https://tolgee.io/js-sdk/5.0.0-alpha.1/integrations/react/installation)
54
+ - [Tolgee JS SDK docs](https://tolgee.io/js-sdk)
55
+ - [Tolgee Website](https://tolgee.io)
56
+ - Product (Learn more about the great features)
57
+ - [Dev tools](https://tolgee.io/features/dev-tools)
58
+ - [Translation assistance](https://tolgee.io/features/translation-assistance)
59
+ - [Collaboration](https://tolgee.io/features/collaboration)
60
+ - [Tolgee platform docs](https://tolgee.io/platform)
61
+
62
+
25
63
 
26
64
  ## Installation
27
65
 
28
- First, install the package.
66
+ ```
67
+ npm install @tolgee/react
68
+ ```
29
69
 
30
- npm install @tolgee/react
31
70
 
32
71
  Then use the library in your app:
33
72
 
34
73
  ```typescript jsx
35
- import { TolgeeProvider } from "@tolgee/react";
74
+ import { TolgeeProvider, ReactPlugin, FormatSimple } from "@tolgee/react";
75
+
76
+ const tolgee = Tolgee()
77
+ .use(ReactPlugin())
78
+ .use(FormatSimple())
79
+ .init({
80
+ language: 'en',
81
+ apiUrl: process.env.REACT_APP_TOLGEE_API_URL,
82
+ apiKey: process.env.REACT_APP_TOLGEE_API_KEY
83
+ });
36
84
 
37
- ...
38
85
 
39
86
  <TolgeeProvider
40
- apiUrl={process.env.REACT_APP_TOLGEE_API_URL}
41
- apiKey={process.env.REACT_APP_TOLGEE_API_KEY}
87
+ tolgee={tolgee}
42
88
  >
43
89
  <Your app components>
44
90
  </TolgeeProvider>
@@ -73,20 +119,85 @@ import { useTranslate } from "@tolgee/react";
73
119
 
74
120
  ...
75
121
 
76
- const t = useTranslate();
122
+ const { t } = useTranslate();
77
123
 
78
124
  ...
79
125
 
80
126
  t("key_to_translate")
81
127
  ```
82
128
 
129
+
83
130
  ## Prerequisites
84
131
 
85
- 1. You have some React based project
86
- 2. You have generated API key from [Tolgee Cloud](https://app.tolgee.io) or self-hosted Tolgee instance.
132
+ 1. You have some React-based project
133
+ 2. You have generated an API key from [Tolgee Cloud](https://app.tolgee.io) or a self-hosted Tolgee instance.
134
+
135
+
136
+
137
+ ## Why to use Tolgee?
138
+ Because it saves a lot of time, you would spend on localization tasks without it. Because it enables you to provide perfectly translated software.
139
+
140
+ ### Features
141
+
142
+ - All-in-one localization solution for your JS application 🙌
143
+ - Out-of-box in-context localization 🎉
144
+ - Automated screenshot generation 📷
145
+ - Translation management platform 🎈
146
+ - Open-source 🔥
147
+
148
+ ![Frame 47](https://user-images.githubusercontent.com/18496315/188637819-ac4eb02d-7859-4ca8-9807-27818a52782d.png)
149
+ Read more on the [Tolgee website](https://tolgee.io)
150
+
151
+
152
+ ## Development
153
+
154
+ We welcome your PRs.
155
+
156
+ To develop the package locally:
157
+ 1. Clone [the repository](https://github.com/tolgee/tolgee-js)
158
+ 1. Install the packages in the repository root
159
+ ```
160
+ pnpm install
161
+ ```
162
+
163
+
164
+ 1. Run the development script
165
+ ```
166
+ pnpm develop:react
167
+ ```
168
+ This runs the development suite of this monorepo for the `react` integration. The changes in each dependency package are
169
+ automatically built and propagated to the test application, which you can open and play within the browser.
170
+
171
+
172
+
173
+
174
+ ### Testing
175
+
176
+ To run Jest tests of this package, execute
177
+ ```
178
+ npm run test
179
+ ```
180
+ In the `/packages/react` directory.
181
+
182
+
183
+
184
+
185
+ ### End-to-end (e2e) testing
186
+ To run the e2e tests, simply execute
187
+ ```
188
+ pnpm run e2e run react
189
+ ```
190
+
191
+ To open and play with e2e tests, run:
192
+ ```
193
+ pnpm run e2e open react
194
+ ```
195
+
196
+
87
197
 
88
- ## Quick integration guide
198
+ ## Contributors
89
199
 
90
- ![react-integrate-infinite](https://user-images.githubusercontent.com/18496315/137310546-d4addbe2-4825-4262-bd18-b731b1941bce.gif)
200
+ <a href="https://github.com/tolgee/tolgee-platform/graphs/contributors">
201
+ <img alt="contributors" src="https://contrib.rocks/image?repo=tolgee/tolgee-js"/>
202
+ </a>
91
203
 
92
- Learn more at our [documentation website 📖](https://tolgee.io).
package/README.njk.md ADDED
@@ -0,0 +1,84 @@
1
+ {% import "../../readmeMacros/macros.njk.md" as macros %}
2
+ {{ macros.header('Tolgee for React', 'The Tolgee i18n SDK for React', packageName) }}
3
+
4
+ # What is Tolgee for React?
5
+ React integration library of Tolgee. This package makes it super simple to add i18n to your React app!
6
+ For more information about using Tolgee with React, visit the [docs 📖](https://tolgee.io/integrations/react).
7
+
8
+ Localize (translate) your CRA, Gatsby, Next.js, or other React projects to multiple languages with Tolgee. Integration of Tolgee is extremely simple! 🇯🇵 🇰🇷 🇩🇪 🇨🇳 🇺🇸 🇫🇷 🇪🇸 🇮🇹 🇷🇺 🇬🇧
9
+
10
+ {{ macros.integrationLinks('Tolgee for React docs', macros.v5link('integrations/react/installation')) }}
11
+
12
+ {{ macros.installation('react') }}
13
+
14
+ Then use the library in your app:
15
+
16
+ ```typescript jsx
17
+ import { TolgeeProvider, ReactPlugin, FormatSimple } from "@tolgee/react";
18
+
19
+ const tolgee = Tolgee()
20
+ .use(ReactPlugin())
21
+ .use(FormatSimple())
22
+ .init({
23
+ language: 'en',
24
+ apiUrl: process.env.REACT_APP_TOLGEE_API_URL,
25
+ apiKey: process.env.REACT_APP_TOLGEE_API_KEY
26
+ });
27
+
28
+
29
+ <TolgeeProvider
30
+ tolgee={tolgee}
31
+ >
32
+ <Your app components>
33
+ </TolgeeProvider>
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ ![react-infinite](https://user-images.githubusercontent.com/18496315/137308502-844f5ccf-1895-414d-bf40-6707cb691853.gif)
39
+
40
+ To translate texts using Tolgee React integration, you can use `T` component or `useTranslate` hook.
41
+
42
+ ### T component
43
+
44
+ ```typescript jsx
45
+ import { T } from "@tolgee/react";
46
+
47
+ ...
48
+
49
+ <T>translation_key</T>
50
+ ```
51
+
52
+ or
53
+
54
+ ```typescript jsx
55
+ <T keyName="translation_key">Default value</T>
56
+ ```
57
+
58
+ ### useTranslate hook
59
+
60
+ ```javascript
61
+ import { useTranslate } from "@tolgee/react";
62
+
63
+ ...
64
+
65
+ const { t } = useTranslate();
66
+
67
+ ...
68
+
69
+ t("key_to_translate")
70
+ ```
71
+
72
+ {{ macros.prereq('React') }}
73
+
74
+ {{ macros.why() }}
75
+
76
+ ## Development
77
+ {{ macros.developmentInstallation() }}
78
+ {{ macros.development('react') }}
79
+
80
+ {{ macros.developmentTesting('/packages/react') }}
81
+
82
+ {{ macros.e2eTesting('react') }}
83
+
84
+ {{ macros.contributors() }}
package/dist/T.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FallbackNSTranslation, TranslateParams } from '@tolgee/web';
1
+ import { NsType, TranslateParams } from '@tolgee/web';
2
2
  import { FunctionComponent } from 'react';
3
3
  import { ParamsTags } from './types';
4
4
  declare type TProps = {
@@ -6,7 +6,8 @@ declare type TProps = {
6
6
  children?: string;
7
7
  noWrap?: boolean;
8
8
  keyName?: string;
9
- ns?: FallbackNSTranslation;
9
+ ns?: NsType;
10
+ defaultValue?: string;
10
11
  };
11
12
  export declare const T: FunctionComponent<TProps>;
12
13
  export {};
@@ -4,6 +4,7 @@ import { ReactOptions, TolgeeReactContext } from './types';
4
4
  export declare const DEFAULT_REACT_OPTIONS: ReactOptions;
5
5
  export declare const TolgeeProviderContext: React.Context<TolgeeReactContext | undefined>;
6
6
  declare type Props = {
7
+ children?: React.ReactNode;
7
8
  tolgee: TolgeeInstance;
8
9
  options?: ReactOptions;
9
10
  fallback?: React.ReactNode;
package/dist/hooks.d.ts CHANGED
@@ -1 +1,4 @@
1
- export declare const useRerender: () => () => void;
1
+ export declare const useRerender: () => {
2
+ instance: number;
3
+ rerender: () => void;
4
+ };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,6 @@ export { useTranslate } from './useTranslate';
2
2
  export { TolgeeProvider, TolgeeProviderContext } from './TolgeeProvider';
3
3
  export { T } from './T';
4
4
  export { useTolgee } from './useTolgee';
5
- export { ReactPlugin } from './ReactPlugin';
5
+ export { GlobalContextPlugin } from './GlobalContextPlugin';
6
6
  export * from './types';
7
7
  export * from '@tolgee/web';
@@ -1,4 +1,5 @@
1
+ import { TranslateParams } from '@tolgee/web';
1
2
  import React from 'react';
2
3
  import { ParamsTags } from './types';
3
- export declare const wrapTagHandlers: (params: ParamsTags) => any;
4
+ export declare const wrapTagHandlers: (params: TranslateParams<ParamsTags> | undefined) => any;
4
5
  export declare const addReactKeys: (val: React.ReactNode | React.ReactNode[] | undefined) => React.ReactNode;
@@ -79,10 +79,9 @@ var TolgeeProvider = function (_a) {
79
79
  }, []);
80
80
  var optionsWithDefault = __assign(__assign({}, DEFAULT_REACT_OPTIONS), options);
81
81
  if (optionsWithDefault.useSuspense) {
82
- return (React__default["default"].createElement(TolgeeProviderContext.Provider, { value: { tolgee: tolgee, options: optionsWithDefault } },
83
- React__default["default"].createElement(React.Suspense, { fallback: fallback || null }, children)));
82
+ return (React__default["default"].createElement(TolgeeProviderContext.Provider, { value: { tolgee: tolgee, options: optionsWithDefault } }, loading ? (fallback) : (React__default["default"].createElement(React.Suspense, { fallback: fallback || null }, children))));
84
83
  }
85
- return (React__default["default"].createElement(TolgeeProviderContext.Provider, { value: { tolgee: tolgee, options: optionsWithDefault } }, fallback && loading ? fallback : children));
84
+ return (React__default["default"].createElement(TolgeeProviderContext.Provider, { value: { tolgee: tolgee, options: optionsWithDefault } }, loading ? fallback : children));
86
85
  };
87
86
 
88
87
  var globalContext;
@@ -102,60 +101,58 @@ function getGlobalContext() {
102
101
  var useTolgeeContext = function () {
103
102
  var context = React.useContext(TolgeeProviderContext) || getGlobalContext();
104
103
  if (!context) {
105
- throw new Error("Couldn't find tolgee instance, did you forgot to use `ReactPlugin`?");
104
+ throw new Error("Couldn't find tolgee instance, did you forgot to use `TolgeeProvider`?");
106
105
  }
107
106
  return context;
108
107
  };
109
108
 
109
+ var useRerender = function () {
110
+ var _a = __read(React.useState(0), 2), instance = _a[0], setCounter = _a[1];
111
+ var rerender = React.useCallback(function () {
112
+ setCounter(function (num) { return num + 1; });
113
+ }, [setCounter]);
114
+ return { instance: instance, rerender: rerender };
115
+ };
116
+
110
117
  var useTranslateInternal = function (ns, options) {
111
118
  var _a = useTolgeeContext(), tolgee = _a.tolgee, defaultOptions = _a.options;
112
119
  var namespaces = web.getFallback(ns);
113
120
  var namespacesJoined = web.getFallbackArray(namespaces).join(':');
114
121
  var currentOptions = __assign(__assign({}, defaultOptions), options);
115
122
  // dummy state to enable re-rendering
116
- var _b = __read(React.useState(0), 2), instance = _b[0], setInstance = _b[1];
117
- var forceRerender = React.useCallback(function () {
118
- setInstance(function (v) { return v + 1; });
119
- }, [setInstance]);
123
+ var _b = useRerender(), rerender = _b.rerender, instance = _b.instance;
120
124
  var subscriptionRef = React.useRef();
121
125
  var subscriptionQueue = React.useRef([]);
122
- var subscribeToKey = function (key) {
123
- if (subscriptionRef.current) {
124
- subscriptionRef.current.subscribeKey(key);
125
- }
126
- else {
127
- subscriptionQueue.current.push(key);
128
- }
126
+ subscriptionQueue.current = [];
127
+ var subscribeToNs = function (ns) {
128
+ var _a;
129
+ subscriptionQueue.current.push(ns);
130
+ (_a = subscriptionRef.current) === null || _a === void 0 ? void 0 : _a.subscribeNs(ns);
129
131
  };
130
- React.useEffect(function () {
131
- subscriptionRef.current = tolgee.onKeyUpdate(forceRerender);
132
- subscriptionQueue.current.forEach(function (key) {
133
- subscriptionRef.current.subscribeKey(key);
134
- });
135
- subscriptionQueue.current = [];
136
- return function () {
137
- subscriptionRef.current.unsubscribe();
138
- };
139
- }, []);
140
132
  var isLoaded = tolgee.isLoaded(namespaces);
141
133
  React.useEffect(function () {
134
+ var subscription = tolgee.onNsUpdate(rerender);
135
+ subscriptionRef.current = subscription;
142
136
  if (!isLoaded) {
143
- subscriptionRef.current.subscribeNs(namespaces);
144
- return function () {
145
- subscriptionRef.current.unsubscribeNs(namespaces);
146
- };
137
+ subscription.subscribeNs(namespaces);
147
138
  }
148
- }, [namespacesJoined, isLoaded]);
139
+ subscriptionQueue.current.forEach(function (ns) {
140
+ subscription.subscribeNs(ns);
141
+ });
142
+ return function () {
143
+ subscription.unsubscribe();
144
+ };
145
+ }, [isLoaded, namespacesJoined]);
149
146
  React.useEffect(function () {
150
147
  tolgee.addActiveNs(namespaces);
151
148
  return function () { return tolgee.removeActiveNs(namespaces); };
152
149
  }, [namespacesJoined]);
153
150
  var t = React.useCallback(function (props) {
154
151
  var fallbackNs = props.ns || (namespaces === null || namespaces === void 0 ? void 0 : namespaces[0]);
155
- subscribeToKey({ key: props.key, ns: fallbackNs });
152
+ subscribeToNs(fallbackNs);
156
153
  return tolgee.t(__assign(__assign({}, props), { ns: fallbackNs }));
157
154
  }, [tolgee, instance]);
158
- if ((currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.useSuspense) && !isLoaded) {
155
+ if (currentOptions.useSuspense && !isLoaded) {
159
156
  throw tolgee.addActiveNs(namespaces, true);
160
157
  }
161
158
  return { t: t, isLoading: !isLoaded };
@@ -169,7 +166,7 @@ var useTranslate = function (ns, options) {
169
166
  params[_i] = arguments[_i];
170
167
  }
171
168
  // @ts-ignore
172
- var props = web.getTranslateParams.apply(void 0, __spreadArray([], __read(params), false));
169
+ var props = web.getTranslateProps.apply(void 0, __spreadArray([], __read(params), false));
173
170
  return tInternal(props);
174
171
  }, [tInternal]);
175
172
  return { t: t, isLoading: isLoading };
@@ -190,9 +187,9 @@ var wrapTagHandlers = function (params) {
190
187
  else if (React__default["default"].isValidElement(value)) {
191
188
  var el_1 = value;
192
189
  result[key] = function (chunk) {
193
- return __assign(__assign({}, el_1), { props: __assign(__assign({}, el_1.props), { children: el_1.props.children !== undefined
194
- ? el_1.props.children
195
- : addReactKeys(chunk) }) });
190
+ return el_1.props.children !== undefined
191
+ ? React__default["default"].cloneElement(el_1)
192
+ : React__default["default"].cloneElement(el_1, {}, addReactKeys(chunk));
196
193
  };
197
194
  }
198
195
  else {
@@ -216,7 +213,7 @@ var T = function (props) {
216
213
  // eslint-disable-next-line no-console
217
214
  console.error('T component: keyName not defined');
218
215
  }
219
- var defaultValue = props.keyName ? props.children : undefined;
216
+ var defaultValue = props.defaultValue || (props.keyName ? props.children : undefined);
220
217
  var t = useTranslateInternal().t;
221
218
  var translation = addReactKeys(t({
222
219
  key: key,
@@ -228,17 +225,9 @@ var T = function (props) {
228
225
  return React__default["default"].createElement(React__default["default"].Fragment, null, translation);
229
226
  };
230
227
 
231
- var useRerender = function () {
232
- var _a = __read(React.useState(0), 2); _a[0]; var setCounter = _a[1];
233
- var rerender = React.useCallback(function () {
234
- setCounter(function (num) { return num + 1; });
235
- }, [setCounter]);
236
- return rerender;
237
- };
238
-
239
228
  var useTolgee = function (events) {
240
229
  var tolgee = useTolgeeContext().tolgee;
241
- var rerender = useRerender();
230
+ var rerender = useRerender().rerender;
242
231
  React.useEffect(function () {
243
232
  var listeners = events === null || events === void 0 ? void 0 : events.map(function (e) { return tolgee.on(e, rerender); });
244
233
  return function () {
@@ -248,13 +237,7 @@ var useTolgee = function (events) {
248
237
  return tolgee;
249
238
  };
250
239
 
251
- var ReactPlugin = function (props) {
252
- return function (tolgee) {
253
- return tolgee.use(web.DevTools({ observer: props })).use(GlobalContextPlugin(props));
254
- };
255
- };
256
-
257
- exports.ReactPlugin = ReactPlugin;
240
+ exports.GlobalContextPlugin = GlobalContextPlugin;
258
241
  exports.T = T;
259
242
  exports.TolgeeProvider = TolgeeProvider;
260
243
  exports.TolgeeProviderContext = TolgeeProviderContext;