fbt-inline-translations 0.2.0 → 0.3.1

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 (80) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +94 -18
  3. package/dist/0d8bb5b3ee5f5dac9e44.woff2 +0 -0
  4. package/dist/176f8f5bd5f02b3abfcf.woff2 +0 -0
  5. package/dist/18d00f739ff1e1c52db1.woff +0 -0
  6. package/dist/2267169ee7270a22a963.woff +0 -0
  7. package/dist/37a7069dc30fc663c878.woff2 +0 -0
  8. package/dist/451d4e559d6f57cdf6a1.woff +0 -0
  9. package/dist/49ae34d4cc6b98c00c69.woff +0 -0
  10. package/dist/7d8125ff7f707231fd89.woff2 +0 -0
  11. package/dist/7f839a8652da29745ce4.woff2 +0 -0
  12. package/dist/865f928cbabcc9f8f2b5.woff +0 -0
  13. package/dist/870c8c1486f76054301a.woff2 +0 -0
  14. package/dist/9360531f9bb817f917f0.woff +0 -0
  15. package/dist/a45108d3b34af91f9113.woff +0 -0
  16. package/dist/b1d9d9904bfca8802a63.woff +0 -0
  17. package/dist/bac8362e7a6ea60b6983.woff +0 -0
  18. package/dist/bd5b7a13f2c52b531a2a.woff +0 -0
  19. package/dist/bundle.js +2 -0
  20. package/dist/bundle.js.LICENSE.txt +67 -0
  21. package/dist/c18ee39fb002ad58b6dc.woff2 +0 -0
  22. package/dist/c20d916c1a1b094c1cec.woff +0 -0
  23. package/dist/c2aa4ab115bf9c6057cb.woff2 +0 -0
  24. package/dist/c64e7e354c88e613c77c.woff2 +0 -0
  25. package/dist/cb5ad999740e9d8a8bd1.woff2 +0 -0
  26. package/dist/cea99d3e3e13a3a599a0.woff +0 -0
  27. package/dist/d022bc70dc1bf7b3425d.woff2 +0 -0
  28. package/dist/f5b74d7ffcdf85b9dd60.woff2 +0 -0
  29. package/dist/index.html +244 -0
  30. package/lib/App.css +2 -444
  31. package/lib/TranslationDialog.d.ts +8 -20
  32. package/lib/TranslationDialog.js +36 -57
  33. package/lib/components/ActionButtons.d.ts +6 -0
  34. package/lib/components/ActionButtons.js +34 -0
  35. package/lib/components/Candidate.d.ts +7 -9
  36. package/lib/components/Candidate.js +29 -6
  37. package/lib/components/Glossary.d.ts +7 -0
  38. package/lib/components/Glossary.js +5 -0
  39. package/lib/components/Modal.d.ts +13 -0
  40. package/lib/components/Modal.js +75 -0
  41. package/lib/components/PhraseOverview.d.ts +3 -7
  42. package/lib/components/PhraseOverview.js +9 -5
  43. package/lib/components/TranslationCard.d.ts +8 -8
  44. package/lib/components/TranslationCard.js +62 -66
  45. package/lib/components/TranslationComposer.d.ts +3 -0
  46. package/lib/components/TranslationComposer.js +17 -0
  47. package/lib/contexts/PhraseContext.d.ts +9 -0
  48. package/lib/contexts/PhraseContext.js +3 -0
  49. package/lib/contexts/SwiftyperServiceContext.d.ts +4 -8
  50. package/lib/contexts/SwiftyperServiceContext.js +3 -21
  51. package/lib/contexts/TranslationContext.d.ts +17 -0
  52. package/lib/contexts/TranslationContext.js +3 -0
  53. package/lib/index.d.ts +14 -11
  54. package/lib/index.js +50 -24
  55. package/lib/providers/PhraseProvider.d.ts +8 -0
  56. package/lib/providers/PhraseProvider.js +11 -0
  57. package/lib/providers/SwiftyperServiceProvider.d.ts +6 -0
  58. package/lib/providers/SwiftyperServiceProvider.js +20 -0
  59. package/lib/providers/TranslationProvider.d.ts +6 -0
  60. package/lib/providers/TranslationProvider.js +23 -0
  61. package/lib/providers/swiftyper.d.ts +13 -13
  62. package/lib/providers/swiftyper.js +7 -7
  63. package/lib/services/SwiftyperService.d.ts +11 -11
  64. package/lib/services/SwiftyperService.js +33 -33
  65. package/lib/{@types → types}/Phrase.d.ts +61 -61
  66. package/lib/{@types → types}/Phrase.js +1 -1
  67. package/lib/{@types → types}/SwiftyperContextType.d.ts +5 -5
  68. package/lib/{@types → types}/SwiftyperContextType.js +1 -1
  69. package/lib/types/Theme.d.ts +2 -0
  70. package/lib/types/Theme.js +9 -0
  71. package/lib/{@types → types}/Translation.d.ts +16 -16
  72. package/lib/{@types → types}/Translation.js +1 -1
  73. package/package.json +74 -74
  74. package/lib/App.d.ts +0 -20
  75. package/lib/App.js +0 -55
  76. package/lib/components/Composer.d.ts +0 -15
  77. package/lib/components/Composer.js +0 -8
  78. package/lib/components/Rodal.d.ts +0 -57
  79. package/lib/components/Rodal.js +0 -111
  80. package/lib/rodal.css +0 -477
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
@@ -1,4 +1,4 @@
1
- # 👽 Inline translations for FBT
1
+ # 👽 Inline Translations for FBT
2
2
 
3
3
  The extension serves to effectively translate your application using inline translations so that you can view strings you are
4
4
  translating in context.
@@ -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
  ![Demo of FBT inline translating](https://raw.githubusercontent.com/swiftyper-sk/fbt-inline-translations/main/images/demo.gif)
12
14
 
13
15
 
14
- ## ℹ️ Usage notes
16
+ ## ℹ️ Prerequisites
15
17
 
16
- - this library requires FBT for PHP:
18
+ This library requires one of the following 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)
19
23
 
20
- ## 📦 Installing
24
+ ## ✨ Key Features
21
25
 
22
- ```
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
31
+
32
+ ## 📦 Installation
33
+
34
+ ⚠️ **React 15 or higher is required.**
35
+
36
+ Install the plugin using npm or yarn:
37
+
38
+ ```bash
23
39
  npm install fbt-inline-translations
40
+ # or
41
+ yarn add fbt-inline-translations
24
42
  ```
25
43
 
26
- ### How to add polyfills in Webpack 5
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,29 +79,75 @@ module.exports = {
63
79
 
64
80
  and
65
81
 
66
- ```cmd
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
- ### Non-React usage
132
+ | **Option** | **Type** | **Description** |
133
+ |---------------|----------|-----------------------------------------------------------|
134
+ | `apiKey` | string | API key for authenticating with the translation service. |
135
+ | `locale` | string | Locale setting for translations (e.g., `en_US`, `de_DE`). |
136
+ | `contributor` | string | Contributor email for authentication. |
137
+ | `darkMode` | boolean | Dark mode theme. |
80
138
 
81
- Add this code to your page:
139
+ ## ⚡️ Quick Start
140
+
141
+ ### Non-React Usage
142
+
143
+ Include the following code snippet in your HTML page:
82
144
 
83
145
  ```html
84
146
  <div id="inline-translator"></div>
85
147
 
86
148
  <script src="https://cdn.jsdelivr.net/npm/fbt-inline-translations/dist/bundle.js"></script>
87
149
  <script>
88
- swiftyperInlineTranslations({
150
+ swiftyperInlineTranslations.default({
89
151
  token: 'YOUR_API_KEY_HERE',
90
152
  locale: 'sk_SK', // translation locale
91
153
  contributor: 'contributor@email.com', // contributor must be invited
@@ -94,11 +156,11 @@ Add this code to your page:
94
156
  </script>
95
157
  ```
96
158
 
97
- ### React usage
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
 
101
- ```js
163
+ ```javascript
102
164
  // src/index.js
103
165
 
104
166
  import ReactDOM from 'react-dom';
@@ -115,4 +177,18 @@ ReactDOM.render(
115
177
  </FbtInlineTranslationsWrapper>,
116
178
  document.getElementById('root')
117
179
  );
118
- ```
180
+ ```
181
+
182
+ ## 🧪 Testing
183
+
184
+ ```bash
185
+ npm run start
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