fbt-inline-translations 0.2.0 → 0.3.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/LICENSE +19 -0
- package/README.md +89 -13
- package/dist/0d8bb5b3ee5f5dac9e44.woff2 +0 -0
- package/dist/176f8f5bd5f02b3abfcf.woff2 +0 -0
- package/dist/18d00f739ff1e1c52db1.woff +0 -0
- package/dist/2267169ee7270a22a963.woff +0 -0
- package/dist/37a7069dc30fc663c878.woff2 +0 -0
- package/dist/451d4e559d6f57cdf6a1.woff +0 -0
- package/dist/49ae34d4cc6b98c00c69.woff +0 -0
- package/dist/7d8125ff7f707231fd89.woff2 +0 -0
- package/dist/7f839a8652da29745ce4.woff2 +0 -0
- package/dist/865f928cbabcc9f8f2b5.woff +0 -0
- package/dist/870c8c1486f76054301a.woff2 +0 -0
- package/dist/9360531f9bb817f917f0.woff +0 -0
- package/dist/a45108d3b34af91f9113.woff +0 -0
- package/dist/b1d9d9904bfca8802a63.woff +0 -0
- package/dist/bac8362e7a6ea60b6983.woff +0 -0
- package/dist/bd5b7a13f2c52b531a2a.woff +0 -0
- package/dist/bundle.js +2 -0
- package/dist/bundle.js.LICENSE.txt +67 -0
- package/dist/c18ee39fb002ad58b6dc.woff2 +0 -0
- package/dist/c20d916c1a1b094c1cec.woff +0 -0
- package/dist/c2aa4ab115bf9c6057cb.woff2 +0 -0
- package/dist/c64e7e354c88e613c77c.woff2 +0 -0
- package/dist/cb5ad999740e9d8a8bd1.woff2 +0 -0
- package/dist/cea99d3e3e13a3a599a0.woff +0 -0
- package/dist/d022bc70dc1bf7b3425d.woff2 +0 -0
- package/dist/f5b74d7ffcdf85b9dd60.woff2 +0 -0
- package/dist/index.html +106 -0
- package/lib/App.css +104 -90
- package/lib/TranslationDialog.d.ts +7 -5
- package/lib/TranslationDialog.js +4 -3
- package/lib/components/ActionButtons.d.ts +6 -0
- package/lib/components/ActionButtons.js +30 -0
- package/lib/components/Candidate.d.ts +5 -7
- package/lib/components/Candidate.js +17 -3
- package/lib/components/Glossary.d.ts +7 -0
- package/lib/components/Glossary.js +5 -0
- package/lib/components/PhraseOverview.d.ts +3 -7
- package/lib/components/PhraseOverview.js +5 -2
- package/lib/components/Rodal.d.ts +1 -1
- package/lib/components/TranslationCard.d.ts +4 -4
- package/lib/components/TranslationCard.js +50 -54
- package/lib/components/TranslationComposer.d.ts +3 -0
- package/lib/components/TranslationComposer.js +17 -0
- package/lib/contexts/PhraseContext.d.ts +9 -0
- package/lib/contexts/PhraseContext.js +3 -0
- package/lib/contexts/SwiftyperServiceContext.d.ts +3 -7
- package/lib/contexts/SwiftyperServiceContext.js +3 -21
- package/lib/contexts/TranslationContext.d.ts +17 -0
- package/lib/contexts/TranslationContext.js +3 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +4 -6
- package/lib/providers/PhraseProvider.d.ts +8 -0
- package/lib/providers/PhraseProvider.js +11 -0
- package/lib/providers/SwiftyperServiceProvider.d.ts +6 -0
- package/lib/providers/SwiftyperServiceProvider.js +20 -0
- package/lib/providers/TranslationProvider.d.ts +6 -0
- package/lib/providers/TranslationProvider.js +23 -0
- package/lib/providers/swiftyper.d.ts +3 -3
- package/lib/services/SwiftyperService.d.ts +1 -1
- package/package.json +9 -8
- package/lib/App.d.ts +0 -20
- package/lib/App.js +0 -55
- package/lib/components/Composer.d.ts +0 -15
- package/lib/components/Composer.js +0 -8
- /package/lib/{@types → types}/Phrase.d.ts +0 -0
- /package/lib/{@types → types}/Phrase.js +0 -0
- /package/lib/{@types → types}/SwiftyperContextType.d.ts +0 -0
- /package/lib/{@types → types}/SwiftyperContextType.js +0 -0
- /package/lib/{@types → types}/Translation.d.ts +0 -0
- /package/lib/{@types → types}/Translation.js +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (C) 2022 Swiftyper (https://swiftyper.sk)
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -6,29 +6,45 @@ If you right-click on the underlined string, the translation dialog appears and
|
|
|
6
6
|
|
|
7
7
|
You can make translations available to your translators, users, or the entire community and make your product multilingual.
|
|
8
8
|
|
|
9
|
-
**Translations can also be approved by your trusted translator(s).**
|
|
9
|
+
❇️ **Translations can also be approved by your trusted translator(s).**
|
|
10
|
+
|
|
11
|
+
## 👀 Preview
|
|
10
12
|
|
|
11
13
|

|
|
12
14
|
|
|
13
15
|
|
|
14
|
-
## ℹ️ Usage
|
|
16
|
+
## ℹ️ Usage Notes
|
|
15
17
|
|
|
16
|
-
-
|
|
18
|
+
- This library requires one of these FBT frameworks:
|
|
17
19
|
- [FBT for Laravel (v5.5+)](https://github.com/richardDobron/laravel-fbt)
|
|
18
20
|
- [FBT for PHP (v7.0+)](https://github.com/richardDobron/fbt)
|
|
21
|
+
- [FBT for JavaScript](https://github.com/facebook/fbt)
|
|
22
|
+
- [FBTee for JavaScript](https://github.com/nkzw-tech/fbtee)
|
|
23
|
+
|
|
24
|
+
## ✨ Key Features
|
|
25
|
+
|
|
26
|
+
- 📝 **Inline**: translating for real-time context
|
|
27
|
+
- 📚 **Glossary**: support for consistent terminology
|
|
28
|
+
- 👍 **Voting**: on translation options
|
|
29
|
+
- 🔄 **Variations**: for dynamic content
|
|
30
|
+
- 🌙 **Dark mode**: to match your theme
|
|
19
31
|
|
|
20
32
|
## 📦 Installing
|
|
21
33
|
|
|
22
|
-
|
|
34
|
+
⚠️ **React 15 or higher only.**
|
|
35
|
+
|
|
36
|
+
Install the plugin via npm or yarn:
|
|
37
|
+
|
|
38
|
+
```shell
|
|
23
39
|
npm install fbt-inline-translations
|
|
40
|
+
# or
|
|
41
|
+
yarn add fbt-inline-translations
|
|
24
42
|
```
|
|
25
43
|
|
|
26
|
-
### How to
|
|
44
|
+
### How to Add Polyfills in Webpack 5
|
|
27
45
|
|
|
28
46
|
Errors in the terminal will give hints on how to add the required polyfill.
|
|
29
47
|
|
|
30
|
-
**Example for path module:**
|
|
31
|
-
|
|
32
48
|
In your Webpack config:
|
|
33
49
|
|
|
34
50
|
```javascript
|
|
@@ -63,20 +79,66 @@ module.exports = {
|
|
|
63
79
|
|
|
64
80
|
and
|
|
65
81
|
|
|
66
|
-
```
|
|
82
|
+
```shell
|
|
67
83
|
npm install buffer url path-browserify stream-http https-browserify --save-dev
|
|
68
84
|
# you may need to clear your cache after this change
|
|
69
85
|
rm -fr node_modules/.cache
|
|
70
86
|
```
|
|
71
87
|
|
|
72
|
-
Restart the Dev Server and the error will be gone.
|
|
88
|
+
Restart the Dev Server and the error will be gone.
|
|
89
|
+
|
|
90
|
+
## Instructions for JavaScript Version of FBT Package
|
|
91
|
+
|
|
92
|
+
Copy file [fbt/InlineFbtResult.js](fbt/InlineFbtResult.js) to your project.
|
|
93
|
+
|
|
94
|
+
Register custom `getFbtResult` hook:
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
import { init } from "fbt";
|
|
98
|
+
import FbtResult from "fbt/lib/FbtResult";
|
|
99
|
+
import InlineFbtResult from "./InlineFbtResult";
|
|
100
|
+
|
|
101
|
+
let inlineMode = 'NO_INLINE';
|
|
102
|
+
|
|
103
|
+
if (true) { // enable inline translations
|
|
104
|
+
inlineMode = 'TRANSLATION';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
init({
|
|
108
|
+
hooks: {
|
|
109
|
+
// ...
|
|
110
|
+
getFbtResult: (input) => {
|
|
111
|
+
if (inlineMode && inlineMode !== 'NO_INLINE') {
|
|
112
|
+
return new InlineFbtResult(
|
|
113
|
+
input.contents,
|
|
114
|
+
inlineMode,
|
|
115
|
+
input.patternString,
|
|
116
|
+
input.patternHash,
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return new FbtResult(input.contents, input.errorListener);
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
// ...
|
|
124
|
+
});
|
|
125
|
+
```
|
|
73
126
|
|
|
74
127
|
## 🔧 Configuration
|
|
75
128
|
|
|
76
|
-
Register your FBT project on [Swiftyper Translations](https://translations.swiftyper.sk)
|
|
129
|
+
Register your FBT project on [Swiftyper Translations](https://translations.swiftyper.sk).
|
|
77
130
|
|
|
78
131
|
|
|
79
|
-
|
|
132
|
+
| **Option** | **Type** | **Description** |
|
|
133
|
+
|---------------------------|----------|---------------------------------------------------------------------|
|
|
134
|
+
| `apiKey` | string | API key for authenticating with the help center. |
|
|
135
|
+
| `locale` | string | Locale setting for the translation widget (e.g., `en_US`, `de_DE`). |
|
|
136
|
+
| `contributor` | string | Contributor email for authentication. |
|
|
137
|
+
| `darkMode` | boolean | Dark mode theme. |
|
|
138
|
+
|
|
139
|
+
## ⚡️ Quick Start
|
|
140
|
+
|
|
141
|
+
### Non-React Usage
|
|
80
142
|
|
|
81
143
|
Add this code to your page:
|
|
82
144
|
|
|
@@ -94,7 +156,7 @@ Add this code to your page:
|
|
|
94
156
|
</script>
|
|
95
157
|
```
|
|
96
158
|
|
|
97
|
-
### React
|
|
159
|
+
### React Usage
|
|
98
160
|
|
|
99
161
|
In your application, wrap your `App` component. We recommend adding it around your root component in the `index.js` file.
|
|
100
162
|
|
|
@@ -115,4 +177,18 @@ ReactDOM.render(
|
|
|
115
177
|
</FbtInlineTranslationsWrapper>,
|
|
116
178
|
document.getElementById('root')
|
|
117
179
|
);
|
|
118
|
-
```
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## 🧪 Testing
|
|
183
|
+
|
|
184
|
+
```sh
|
|
185
|
+
npm run dev
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## 🌟 Contributing
|
|
189
|
+
|
|
190
|
+
We welcome contributions! If you'd like to help improve this project, feel free to open an issue or submit a pull request.
|
|
191
|
+
|
|
192
|
+
## 📜 License
|
|
193
|
+
|
|
194
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|