fbt-inline-translations 0.1.6 → 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.
Files changed (75) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +154 -7
  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 +106 -0
  30. package/lib/App.css +424 -25
  31. package/lib/TranslationDialog.d.ts +22 -0
  32. package/lib/{App.js → TranslationDialog.js} +13 -10
  33. package/lib/components/ActionButtons.d.ts +6 -0
  34. package/lib/components/ActionButtons.js +30 -0
  35. package/lib/components/Candidate.d.ts +5 -7
  36. package/lib/components/Candidate.js +17 -3
  37. package/lib/components/Glossary.d.ts +7 -0
  38. package/lib/components/Glossary.js +5 -0
  39. package/lib/components/PhraseOverview.d.ts +3 -7
  40. package/lib/components/PhraseOverview.js +5 -2
  41. package/lib/components/Rodal.d.ts +57 -0
  42. package/lib/components/Rodal.js +111 -0
  43. package/lib/components/TranslationCard.d.ts +5 -4
  44. package/lib/components/TranslationCard.js +52 -47
  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 +3 -3
  54. package/lib/index.js +12 -8
  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 +4 -4
  62. package/lib/providers/swiftyper.js +1 -1
  63. package/lib/rodal.css +477 -0
  64. package/lib/services/SwiftyperService.d.ts +2 -2
  65. package/lib/services/SwiftyperService.js +2 -2
  66. package/lib/{@types → types}/Phrase.d.ts +13 -0
  67. package/package.json +14 -11
  68. package/lib/App.d.ts +0 -20
  69. package/lib/components/Composer.d.ts +0 -13
  70. package/lib/components/Composer.js +0 -8
  71. /package/lib/{@types → types}/Phrase.js +0 -0
  72. /package/lib/{@types → types}/SwiftyperContextType.d.ts +0 -0
  73. /package/lib/{@types → types}/SwiftyperContextType.js +0 -0
  74. /package/lib/{@types → types}/Translation.d.ts +0 -0
  75. /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,139 @@ 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
+ ## ℹ️ Usage Notes
15
17
 
16
- - this library requires FBT for PHP:
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
42
+ ```
43
+
44
+ ### How to Add Polyfills in Webpack 5
45
+
46
+ Errors in the terminal will give hints on how to add the required polyfill.
47
+
48
+ In your Webpack config:
49
+
50
+ ```javascript
51
+ module.exports = {
52
+ resolve: {
53
+ // ...
54
+ fallback: {
55
+ "buffer": require.resolve("buffer/"),
56
+ "url": require.resolve("url/"),
57
+ "path": require.resolve("path-browserify"),
58
+ "http": require.resolve("stream-http"),
59
+ "https": require.resolve("https-browserify"),
60
+ },
61
+
62
+ alias: {
63
+ process: "process/browser",
64
+ },
65
+
66
+ plugins: [
67
+ // Work around for Buffer is undefined:
68
+ // https://github.com/webpack/changelog-v5/issues/10
69
+ new webpack.ProvidePlugin({
70
+ Buffer: ['buffer', 'Buffer'],
71
+ }),
72
+ new webpack.ProvidePlugin({
73
+ process: 'process/browser',
74
+ }),
75
+ ],
76
+ },
77
+ };
78
+ ```
79
+
80
+ and
81
+
82
+ ```shell
83
+ npm install buffer url path-browserify stream-http https-browserify --save-dev
84
+ # you may need to clear your cache after this change
85
+ rm -fr node_modules/.cache
86
+ ```
87
+
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
+ });
24
125
  ```
25
126
 
26
127
  ## 🔧 Configuration
27
128
 
28
- Register your FBT project on [Swiftyper Translations](https://translations.swiftyper.sk)
129
+ Register your FBT project on [Swiftyper Translations](https://translations.swiftyper.sk).
130
+
29
131
 
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. |
30
138
 
31
- ### Non-React usage
139
+ ## ⚡️ Quick Start
140
+
141
+ ### Non-React Usage
32
142
 
33
143
  Add this code to your page:
34
144
 
@@ -44,4 +154,41 @@ Add this code to your page:
44
154
  darkMode: false, // dark mode also depends on html class 'tw-dark'
45
155
  })
46
156
  </script>
47
- ```
157
+ ```
158
+
159
+ ### React Usage
160
+
161
+ In your application, wrap your `App` component. We recommend adding it around your root component in the `index.js` file.
162
+
163
+ ```js
164
+ // src/index.js
165
+
166
+ import ReactDOM from 'react-dom';
167
+ import { FbtInlineTranslationsWrapper } from 'fbt-inline-translations';
168
+
169
+ ReactDOM.render(
170
+ <FbtInlineTranslationsWrapper
171
+ token={'YOUR_API_KEY_HERE'}
172
+ locale={"sk_SK"} // translation locale
173
+ contributor={"contributor@email.com"} // contributor must be invited
174
+ darkMode={false} // dark mode also depends on html class 'tw-dark'
175
+ >
176
+ <App />
177
+ </FbtInlineTranslationsWrapper>,
178
+ document.getElementById('root')
179
+ );
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