@tolgee/core 5.0.0-rc.9be0f0e.0 → 5.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 +174 -0
- package/README.njk.md +61 -0
- package/dist/tolgee.cjs.js +723 -351
- package/dist/tolgee.cjs.js.map +1 -1
- package/dist/tolgee.cjs.min.js +1 -1
- package/dist/tolgee.cjs.min.js.map +1 -1
- package/dist/{tolgee.esm.mjs → tolgee.esm.js} +722 -346
- package/dist/tolgee.esm.js.map +1 -0
- package/dist/tolgee.esm.min.mjs +1 -1
- package/dist/tolgee.esm.min.mjs.map +1 -1
- package/dist/tolgee.umd.js +723 -351
- package/dist/tolgee.umd.js.map +1 -1
- package/dist/tolgee.umd.min.js +1 -1
- package/dist/tolgee.umd.min.js.map +1 -1
- package/lib/Controller/Cache/Cache.d.ts +10 -9
- package/lib/Controller/Controller.d.ts +104 -45
- package/lib/Controller/Events/EventEmitter.d.ts +6 -0
- package/lib/Controller/Events/EventEmitterSelective.d.ts +7 -0
- package/lib/Controller/Events/Events.d.ts +14 -0
- package/lib/Controller/Plugins/Plugins.d.ts +12 -25
- package/lib/Controller/State/State.d.ts +27 -9
- package/lib/Controller/State/initState.d.ts +46 -15
- package/lib/Controller/State/observerOptions.d.ts +41 -0
- package/lib/Controller/ValueObserver.d.ts +5 -5
- package/lib/FormatSimple/FormatError.d.ts +7 -0
- package/lib/FormatSimple/FormatSimple.d.ts +2 -0
- package/lib/FormatSimple/formatParser.d.ts +1 -0
- package/lib/FormatSimple/formatter.d.ts +2 -0
- package/lib/TolgeeCore.d.ts +204 -0
- package/lib/TranslateParams.d.ts +1 -1
- package/lib/helpers.d.ts +8 -0
- package/lib/index.d.ts +4 -4
- package/lib/types/cache.d.ts +25 -0
- package/lib/types/events.d.ts +66 -0
- package/lib/types/general.d.ts +34 -0
- package/lib/types/index.d.ts +7 -0
- package/lib/types/plugin.d.ts +127 -0
- package/package.json +5 -4
- package/src/Controller/Cache/Cache.ts +31 -31
- package/src/Controller/Cache/helpers.ts +6 -6
- package/src/Controller/Controller.ts +78 -50
- package/src/Controller/Events/EventEmitter.ts +34 -0
- package/src/Controller/Events/EventEmitterSelective.test.ts +110 -0
- package/src/Controller/Events/EventEmitterSelective.ts +132 -0
- package/src/Controller/Events/Events.ts +69 -0
- package/src/Controller/Plugins/Plugins.ts +182 -133
- package/src/Controller/State/State.ts +43 -26
- package/src/Controller/State/initState.ts +97 -25
- package/src/Controller/State/observerOptions.ts +66 -0
- package/src/Controller/ValueObserver.ts +5 -2
- package/src/FormatSimple/FormatError.ts +26 -0
- package/src/FormatSimple/FormatSimple.ts +13 -0
- package/src/FormatSimple/formatParser.ts +133 -0
- package/src/FormatSimple/formatter.test.ts +190 -0
- package/src/FormatSimple/formatter.ts +19 -0
- package/src/TolgeeCore.ts +267 -0
- package/src/TranslateParams.test.ts +9 -12
- package/src/TranslateParams.ts +6 -5
- package/src/__test/backend.test.ts +6 -6
- package/src/__test/cache.test.ts +190 -0
- package/src/__test/client.test.ts +2 -2
- package/src/__test/events.test.ts +32 -7
- package/src/__test/format.simple.test.ts +14 -0
- package/src/__test/formatError.test.ts +61 -0
- package/src/__test/initialization.test.ts +15 -3
- package/src/__test/languageDetection.test.ts +14 -8
- package/src/__test/languageStorage.test.ts +10 -11
- package/src/__test/languages.test.ts +30 -6
- package/src/__test/loading.test.ts +2 -2
- package/src/__test/{namespacesFallback.test.ts → namespaces.fallback.test.ts} +10 -8
- package/src/__test/namespaces.test.ts +30 -7
- package/src/__test/options.test.ts +64 -0
- package/src/__test/plugins.test.ts +29 -18
- package/src/helpers.ts +53 -0
- package/src/index.ts +4 -10
- package/src/types/cache.ts +37 -0
- package/src/types/events.ts +85 -0
- package/src/types/general.ts +50 -0
- package/src/types/index.ts +19 -0
- package/src/types/plugin.ts +181 -0
- package/dist/tolgee.esm.mjs.map +0 -1
- package/lib/Controller/State/helpers.d.ts +0 -6
- package/lib/Events/EventEmitter.d.ts +0 -6
- package/lib/Events/EventEmitterSelective.d.ts +0 -15
- package/lib/Events/Events.d.ts +0 -50
- package/lib/Tolgee.d.ts +0 -2
- package/lib/constants.d.ts +0 -5
- package/lib/types.d.ts +0 -274
- package/src/Controller/State/helpers.ts +0 -41
- package/src/Events/EventEmitter.ts +0 -27
- package/src/Events/EventEmitterSelective.test.ts +0 -108
- package/src/Events/EventEmitterSelective.ts +0 -160
- package/src/Events/Events.ts +0 -66
- package/src/Tolgee.ts +0 -77
- package/src/constants.ts +0 -7
- package/src/types.ts +0 -380
package/README.md
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
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
|
+
|
|
8
|
+
<h1 align="center" style="border-bottom: none">
|
|
9
|
+
<b>
|
|
10
|
+
<a href="https://tolgee.io">Tolgee JS Core</a><br>
|
|
11
|
+
</b>
|
|
12
|
+
The Core of Tolgee JS integrations
|
|
13
|
+
<br>
|
|
14
|
+
</h1>
|
|
15
|
+
|
|
16
|
+
<div align="center">
|
|
17
|
+
|
|
18
|
+
[](https://tolgee.io)
|
|
19
|
+
|
|
20
|
+
Tolgee is an open-source alternative to Crowdin, Phrase, or Lokalise with its very own revolutionary integrations.
|
|
21
|
+
|
|
22
|
+

|
|
23
|
+
|
|
24
|
+

|
|
25
|
+
|
|
26
|
+

|
|
27
|
+

|
|
28
|
+

|
|
29
|
+
[](https://github.com/tolgee/tolgee-js)
|
|
30
|
+
[](https://github.com/tolgee/server)
|
|
31
|
+
[](https://github.com/tolgee/tolgee-platform/discussions)
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<div align="center">
|
|
35
|
+
|
|
36
|
+
[<img src="https://img.shields.io/badge/-Facebook-424549?style=social&logo=facebook" height=25 />](https://www.facebook.com/Tolgee.i18n)
|
|
37
|
+
[<img src="https://img.shields.io/badge/-Twitter-424549?style=social&logo=twitter" height=25 />](https://twitter.com/Tolgee_i18n)
|
|
38
|
+
[<img src="https://img.shields.io/badge/-Linkedin-424549?style=social&logo=linkedin" height=25 />](https://www.linkedin.com/company/tolgee)
|
|
39
|
+
|
|
40
|
+
**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)**
|
|
41
|
+
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## What is Tolgee JS Core?
|
|
47
|
+
It's the core library of Tolgee JS integrations containing the platform-agnostic parts of the Tolgee JS.
|
|
48
|
+
For more information about Tolgee JS integrations, visit the [docs](https://tolgee.io/js-sdk/5.0.0-alpha.1/).
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
## Quick links
|
|
52
|
+
- [Tolgee JS SDK docs](https://tolgee.io/js-sdk)
|
|
53
|
+
- [Tolgee Website](https://tolgee.io)
|
|
54
|
+
- Product (Learn more about the great features)
|
|
55
|
+
- [Dev tools](https://tolgee.io/features/dev-tools)
|
|
56
|
+
- [Translation assistance](https://tolgee.io/features/translation-assistance)
|
|
57
|
+
- [Collaboration](https://tolgee.io/features/collaboration)
|
|
58
|
+
- Integrations (Learn how to integrate Tolgee with your favorite technology)
|
|
59
|
+
- [React](https://tolgee.io/integrations/react)
|
|
60
|
+
- [Angular](https://tolgee.io/integrations/angular)
|
|
61
|
+
- [Vue](https://tolgee.io/integrations/vue)
|
|
62
|
+
- [Svelte](https://tolgee.io/integrations/svelte)
|
|
63
|
+
- [Next.js](https://tolgee.io/integrations/next)
|
|
64
|
+
- [Gatsby](https://tolgee.io/integrations/gatsby)
|
|
65
|
+
- [More...](https://tolgee.io/integrations/all)
|
|
66
|
+
- [Tolgee platform docs](https://tolgee.io/platform)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
## You should not use this package directly for usage in the web browser
|
|
70
|
+
|
|
71
|
+
If you use Tolgee on the web, use [@tolgee/web](https://github.com/tolgee/tolgee-js/tree/main/packages/web) package, which extends this package with web-related functionality.
|
|
72
|
+
|
|
73
|
+
This package is platform-agnostic, so it contains only the most general functionality.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## Installation
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
npm install @tolgee/core
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## Usage
|
|
84
|
+
|
|
85
|
+
First, create a Tolgee instance and run it.
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { TolgeeCore } from "@tolgee/core";
|
|
89
|
+
|
|
90
|
+
const tg = TolgeeCore()
|
|
91
|
+
.use(...)
|
|
92
|
+
.init(...)
|
|
93
|
+
|
|
94
|
+
tg.run();
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
To learn more, check [the docs](https://tolgee.io/js-sdk/5.0.0-alpha.1/).
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
## Why to use Tolgee?
|
|
101
|
+
Because it saves a lot of time, you would spend on localization tasks without it. Because it enables you to provide perfectly translated software.
|
|
102
|
+
|
|
103
|
+
### Features
|
|
104
|
+
|
|
105
|
+
- All-in-one localization solution for your JS application 🙌
|
|
106
|
+
- Out-of-box in-context localization 🎉
|
|
107
|
+
- Automated screenshot generation 📷
|
|
108
|
+
- Translation management platform 🎈
|
|
109
|
+
- Open-source 🔥
|
|
110
|
+
|
|
111
|
+

|
|
112
|
+
Read more on the [Tolgee website](https://tolgee.io)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
## Development
|
|
116
|
+
|
|
117
|
+
We welcome your PRs.
|
|
118
|
+
|
|
119
|
+
To develop the package locally:
|
|
120
|
+
1. Clone [the repository](https://github.com/tolgee/tolgee-js)
|
|
121
|
+
1. Install the packages in the repository root
|
|
122
|
+
```
|
|
123
|
+
pnpm install
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
1. Run web or any integration development script
|
|
128
|
+
```
|
|
129
|
+
pnpm develop:react
|
|
130
|
+
```
|
|
131
|
+
or
|
|
132
|
+
```
|
|
133
|
+
pnpm develop:web
|
|
134
|
+
```
|
|
135
|
+
This runs the development suite of this monorepo for the specific integration. The changes in each dependency package are
|
|
136
|
+
automatically built and propagated to the test application, which you can open and play within the browser.
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
### Testing
|
|
142
|
+
|
|
143
|
+
To run Jest tests of this package, execute
|
|
144
|
+
```
|
|
145
|
+
npm run test
|
|
146
|
+
```
|
|
147
|
+
In the `/packages/core` directory.
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
### End-to-end (e2e) testing
|
|
151
|
+
|
|
152
|
+
Each integration is end-to-end tested via cypress. The tests are defined in `/e2e/cypress/e2e` directory.
|
|
153
|
+
|
|
154
|
+
To run the e2e tests, run
|
|
155
|
+
```
|
|
156
|
+
pnpm run e2e run <integration>
|
|
157
|
+
```
|
|
158
|
+
E.g.
|
|
159
|
+
```
|
|
160
|
+
pnpm run e2e run web
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
To open and play with e2e tests, run:
|
|
164
|
+
```
|
|
165
|
+
pnpm run e2e open <integration>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
## Contributors
|
|
170
|
+
|
|
171
|
+
<a href="https://github.com/tolgee/tolgee-platform/graphs/contributors">
|
|
172
|
+
<img alt="contributors" src="https://contrib.rocks/image?repo=tolgee/tolgee-js"/>
|
|
173
|
+
</a>
|
|
174
|
+
|
package/README.njk.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{% import "../../readmeMacros/macros.njk.md" as macros %}
|
|
2
|
+
|
|
3
|
+
{{ macros.header('Tolgee JS Core', 'The Core of Tolgee JS integrations', packageName) }}
|
|
4
|
+
|
|
5
|
+
## What is Tolgee JS Core?
|
|
6
|
+
It's the core library of Tolgee JS integrations containing the platform-agnostic parts of the Tolgee JS.
|
|
7
|
+
For more information about Tolgee JS integrations, visit the [docs]({{ macros.v5link() }}).
|
|
8
|
+
|
|
9
|
+
{{ macros.links() }}
|
|
10
|
+
|
|
11
|
+
## You should not use this package directly for usage in the web browser
|
|
12
|
+
|
|
13
|
+
If you use Tolgee on the web, use [@tolgee/web](https://github.com/tolgee/tolgee-js/tree/main/packages/web) package, which extends this package with web-related functionality.
|
|
14
|
+
|
|
15
|
+
This package is platform-agnostic, so it contains only the most general functionality.
|
|
16
|
+
|
|
17
|
+
{{ macros.installation('core') }}
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
First, create a Tolgee instance and run it.
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { TolgeeCore } from "@tolgee/core";
|
|
25
|
+
|
|
26
|
+
const tg = TolgeeCore()
|
|
27
|
+
.use(...)
|
|
28
|
+
.init(...)
|
|
29
|
+
|
|
30
|
+
tg.run();
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
To learn more, check [the docs]({{ macros.v5link() }}).
|
|
34
|
+
|
|
35
|
+
{{ macros.why() }}
|
|
36
|
+
|
|
37
|
+
## Development
|
|
38
|
+
{{ macros.developmentInstallation() }}
|
|
39
|
+
{{ macros.developmentCore() }}
|
|
40
|
+
|
|
41
|
+
{{ macros.developmentTesting('/packages/core') }}
|
|
42
|
+
|
|
43
|
+
### End-to-end (e2e) testing
|
|
44
|
+
|
|
45
|
+
Each integration is end-to-end tested via cypress. The tests are defined in `/e2e/cypress/e2e` directory.
|
|
46
|
+
|
|
47
|
+
To run the e2e tests, run
|
|
48
|
+
```
|
|
49
|
+
pnpm run e2e run <integration>
|
|
50
|
+
```
|
|
51
|
+
E.g.
|
|
52
|
+
```
|
|
53
|
+
pnpm run e2e run web
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
To open and play with e2e tests, run:
|
|
57
|
+
```
|
|
58
|
+
pnpm run e2e open <integration>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
{{ macros.contributors() }}
|