@lovalingo/lovalingo 0.0.11

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 (49) hide show
  1. package/LICENSE +148 -0
  2. package/README.md +376 -0
  3. package/dist/components/AixsterProvider.d.ts +9 -0
  4. package/dist/components/AixsterProvider.js +495 -0
  5. package/dist/components/AutoTranslate.d.ts +10 -0
  6. package/dist/components/AutoTranslate.js +77 -0
  7. package/dist/components/LangLink.d.ts +20 -0
  8. package/dist/components/LangLink.js +28 -0
  9. package/dist/components/LangRouter.d.ts +34 -0
  10. package/dist/components/LangRouter.js +60 -0
  11. package/dist/components/LanguageSwitcher.d.ts +10 -0
  12. package/dist/components/LanguageSwitcher.js +162 -0
  13. package/dist/components/LovalingoProvider.d.ts +1 -0
  14. package/dist/components/LovalingoProvider.js +1 -0
  15. package/dist/components/NavigationOverlay.d.ts +6 -0
  16. package/dist/components/NavigationOverlay.js +47 -0
  17. package/dist/context/AixsterContext.d.ts +3 -0
  18. package/dist/context/AixsterContext.js +2 -0
  19. package/dist/context/LovalingoContext.d.ts +1 -0
  20. package/dist/context/LovalingoContext.js +1 -0
  21. package/dist/hooks/useAixster.d.ts +6 -0
  22. package/dist/hooks/useAixster.js +14 -0
  23. package/dist/hooks/useAixsterEdit.d.ts +5 -0
  24. package/dist/hooks/useAixsterEdit.js +13 -0
  25. package/dist/hooks/useAixsterTranslate.d.ts +4 -0
  26. package/dist/hooks/useAixsterTranslate.js +12 -0
  27. package/dist/hooks/useLang.d.ts +16 -0
  28. package/dist/hooks/useLang.js +20 -0
  29. package/dist/hooks/useLangNavigate.d.ts +24 -0
  30. package/dist/hooks/useLangNavigate.js +30 -0
  31. package/dist/hooks/useLovalingo.d.ts +1 -0
  32. package/dist/hooks/useLovalingo.js +1 -0
  33. package/dist/hooks/useLovalingoEdit.d.ts +1 -0
  34. package/dist/hooks/useLovalingoEdit.js +1 -0
  35. package/dist/hooks/useLovalingoTranslate.d.ts +1 -0
  36. package/dist/hooks/useLovalingoTranslate.js +1 -0
  37. package/dist/index.d.ts +25 -0
  38. package/dist/index.js +27 -0
  39. package/dist/types.d.ts +65 -0
  40. package/dist/types.js +1 -0
  41. package/dist/utils/api.d.ts +17 -0
  42. package/dist/utils/api.js +145 -0
  43. package/dist/utils/hash.d.ts +9 -0
  44. package/dist/utils/hash.js +27 -0
  45. package/dist/utils/pathNormalizer.d.ts +49 -0
  46. package/dist/utils/pathNormalizer.js +114 -0
  47. package/dist/utils/translator.d.ts +80 -0
  48. package/dist/utils/translator.js +766 -0
  49. package/package.json +50 -0
package/LICENSE ADDED
@@ -0,0 +1,148 @@
1
+ LOVALINGO COMMERCIAL LICENSE
2
+
3
+ Copyright (c) 2025 Mertens Advies. All rights reserved.
4
+
5
+ NOTICE: This software and associated documentation files (the "Software") are the
6
+ proprietary and confidential information of Mertens Advies.
7
+
8
+ The Software is licensed, not sold. This license grants you the following rights:
9
+
10
+ ====================================================================================
11
+ 1. PERMITTED USES
12
+ ====================================================================================
13
+
14
+ Subject to the terms of this license, you are granted a non-exclusive right to:
15
+
16
+ ✓ USE the Software as a translation library in your applications and websites
17
+
18
+ ✓ INTEGRATE the Software into client projects if you are a development agency,
19
+ freelancer, or service provider
20
+
21
+ ✓ DEPLOY compiled/bundled versions of the Software in client applications
22
+
23
+ ✓ CHARGE CLIENTS for integration, development, and consulting services related
24
+ to implementing the Software
25
+
26
+ ✓ PROVIDE END CLIENTS with usage rights to the Software as part of delivered
27
+ applications (end clients receive usage rights through the integrating party)
28
+
29
+ ✓ INSTALL the Software via package managers (npm, yarn, etc.) for development
30
+ and production use
31
+
32
+ ====================================================================================
33
+ 2. PROHIBITED USES
34
+ ====================================================================================
35
+
36
+ You may NOT:
37
+
38
+ ✗ RESELL OR WHITE-LABEL the Software as your own standalone product or service
39
+
40
+ ✗ REDISTRIBUTE the source code or provide clients with access to modify the
41
+ Software's source code
42
+
43
+ ✗ REVERSE ENGINEER, decompile, disassemble, or attempt to derive the source
44
+ code except as compiled in standard application builds
45
+
46
+ ✗ BUILD COMPETING PRODUCTS using the Software's code, algorithms, or concepts
47
+
48
+ ✗ SUBLICENSE the Software to third parties as a standalone product
49
+
50
+ ✗ REMOVE OR ALTER any proprietary notices, labels, or copyright information
51
+
52
+ ✗ EXTRACT OR REUSE portions of the source code for purposes other than using
53
+ the Software as intended
54
+
55
+ ✗ USE THE SOFTWARE in any manner that violates applicable laws or regulations
56
+
57
+ ====================================================================================
58
+ 3. AGENCY & CLIENT DEPLOYMENT CLARIFICATION
59
+ ====================================================================================
60
+
61
+ FOR AGENCIES/DEVELOPERS:
62
+ - You may integrate Lovalingo into unlimited client projects
63
+ - You may charge clients for your development and integration services
64
+ - Compiled code (node_modules, build artifacts) may be deployed to client servers
65
+ - You may not give clients the ability to modify the Software's source code
66
+
67
+ FOR END CLIENTS:
68
+ - Receive usage rights through their agency/developer
69
+ - May run and operate applications containing the Software
70
+ - May not redistribute, modify, or extract the Software
71
+ - Each production deployment should use a valid Lovalingo API key
72
+
73
+ ====================================================================================
74
+ 4. API KEY REQUIREMENT
75
+ ====================================================================================
76
+
77
+ Production use of the Software requires a valid API key obtained from Mertens Advies.
78
+ Usage is subject to the terms of service associated with your API key subscription.
79
+
80
+ ====================================================================================
81
+ 5. INTELLECTUAL PROPERTY
82
+ ====================================================================================
83
+
84
+ This Software is the exclusive intellectual property of Mertens Advies.
85
+ All rights, title, and interest in and to the Software, including all
86
+ intellectual property rights, patents, trademarks, copyrights, and trade secrets,
87
+ remain the sole property of Mertens Advies.
88
+
89
+ ====================================================================================
90
+ 6. NOT OPEN SOURCE
91
+ ====================================================================================
92
+
93
+ This Software is NOT open source. No part of this Software may be used, copied,
94
+ modified, or distributed under any open source license terms. This is proprietary,
95
+ commercial software.
96
+
97
+ ====================================================================================
98
+ 7. TERMINATION
99
+ ====================================================================================
100
+
101
+ This license is effective until terminated. Your rights under this license will
102
+ terminate automatically without notice if you fail to comply with any term of
103
+ this agreement.
104
+
105
+ Upon termination:
106
+ - You must cease all use of the Software
107
+ - Remove the Software from all systems and applications
108
+ - Destroy all copies in your possession
109
+
110
+ ====================================================================================
111
+ 8. DISCLAIMER OF WARRANTY
112
+ ====================================================================================
113
+
114
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
115
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
116
+ PARTICULAR PURPOSE, AND NONINFRINGEMENT. MERTENS ADVIES DOES NOT WARRANT THAT THE
117
+ SOFTWARE WILL BE ERROR-FREE OR UNINTERRUPTED.
118
+
119
+ ====================================================================================
120
+ 9. LIMITATION OF LIABILITY
121
+ ====================================================================================
122
+
123
+ IN NO EVENT SHALL MERTENS ADVIES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
124
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
125
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
126
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
127
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
128
+ IN ANY WAY OUT OF THE USE OF THE SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
129
+ SUCH DAMAGE.
130
+
131
+ ====================================================================================
132
+ 10. GOVERNING LAW
133
+ ====================================================================================
134
+
135
+ This license shall be governed by and construed in accordance with the laws of
136
+ the jurisdiction in which Mertens Advies operates, without regard to its conflict
137
+ of law provisions.
138
+
139
+ ====================================================================================
140
+
141
+ For licensing inquiries, enterprise licensing, or questions about permitted use,
142
+ please contact Mertens Advies.
143
+
144
+ MERTENS ADVIES
145
+ Lovalingo Translation Platform
146
+ © 2025 All Rights Reserved
147
+
148
+ Website: [Contact Mertens Advies for licensing information]
package/README.md ADDED
@@ -0,0 +1,376 @@
1
+ # @aixyte/Lovalingo
2
+
3
+ Seamless website translation for React and Next.js applications with **zero-flash rendering** and **automatic language routing**.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @aixyte/Lovalingo react-router-dom
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ### Option 1: Path Mode (Recommended - Automatic Language URLs)
14
+
15
+ **One-line setup** that automatically handles language routing like `/en/pricing`, `/fr/pricing`, `/de/pricing`:
16
+
17
+ ```tsx
18
+ import { LangRouter, LovalingoProvider } from '@aixyte/Lovalingo';
19
+ import { Routes, Route } from 'react-router-dom';
20
+ import { useRef } from 'react';
21
+
22
+ function App() {
23
+ const navigateRef = useRef();
24
+
25
+ return (
26
+ <LangRouter defaultLang="en" langs={['en', 'fr', 'de', 'es']} navigateRef={navigateRef}>
27
+ <LovalingoProvider
28
+ apiKey="aix_your_api_key"
29
+ defaultLocale="en"
30
+ locales={['en', 'fr', 'de', 'es']}
31
+ routing="path"
32
+ navigateRef={navigateRef}
33
+ >
34
+ <Routes>
35
+ {/* No language prefix needed! */}
36
+ <Route path="/" element={<Home />} />
37
+ <Route path="home" element={<Home />} />
38
+ <Route path="pricing" element={<Pricing />} />
39
+ <Route path="about" element={<About />} />
40
+ </Routes>
41
+ </LovalingoProvider>
42
+ </LangRouter>
43
+ );
44
+ }
45
+ ```
46
+
47
+ **Important:** Pass the same `navigateRef` to both `<LangRouter>` and `<LovalingoProvider>` for proper URL synchronization.
48
+
49
+ URLs automatically work as:
50
+ - `/en/`, `/en/home`, `/en/pricing`, `/en/about`
51
+ - `/fr/`, `/fr/home`, `/fr/pricing`, `/fr/about`
52
+ - `/de/`, `/de/home`, `/de/pricing`, `/de/about`
53
+
54
+ ### Option 2: Query Mode (Simple - Query Parameters)
55
+
56
+ Use query parameters like `/pricing?t=fr`:
57
+
58
+ ```tsx
59
+ import { LovalingoProvider } from '@aixyte/Lovalingo';
60
+ import { BrowserRouter } from 'react-router-dom';
61
+
62
+ function App() {
63
+ return (
64
+ <BrowserRouter>
65
+ <LovalingoProvider
66
+ apiKey="aix_your_api_key"
67
+ defaultLocale="en"
68
+ locales={['en', 'de', 'fr', 'es']}
69
+ routing="query"
70
+ >
71
+ <YourApp />
72
+ </LovalingoProvider>
73
+ </BrowserRouter>
74
+ );
75
+ }
76
+ ```
77
+
78
+ ### Next.js
79
+
80
+ ```tsx
81
+ // app/layout.tsx
82
+ import { LovalingoProvider } from '@aixyte/Lovalingo';
83
+
84
+ export default function RootLayout({ children }) {
85
+ return (
86
+ <html>
87
+ <body>
88
+ <LovalingoProvider
89
+ apiKey="aix_your_api_key"
90
+ defaultLocale="en"
91
+ locales={['en', 'de', 'fr', 'es']}
92
+ >
93
+ {children}
94
+ </LovalingoProvider>
95
+ </body>
96
+ </html>
97
+ );
98
+ }
99
+ ```
100
+
101
+ ## Configuration
102
+
103
+ ```tsx
104
+ <LovalingoProvider
105
+ apiKey="aix_xxx" // Required: Your Lovalingo API key
106
+ defaultLocale="en" // Required: Source language
107
+ locales={['en', 'de', 'fr']} // Required: Supported languages
108
+ apiBase="https://..." // Optional: Custom API endpoint
109
+ routing="query" // Optional: 'query' | 'path' (default: 'query')
110
+ switcherPosition="bottom-right" // Optional: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'
111
+ switcherOffsetY={20} // Optional: Vertical offset in pixels
112
+ editMode={false} // Optional: Enable edit mode
113
+ editKey="KeyE" // Optional: Keyboard shortcut for edit mode
114
+ mode="dom" // Optional: 'dom' | 'context' (default: 'dom')
115
+ sitemap={true} // Optional: Auto-inject sitemap link (default: true) - NEW in v4.2.2
116
+ >
117
+ {children}
118
+ </LovalingoProvider>
119
+ ```
120
+
121
+ ### Routing Modes
122
+
123
+ - **`query`** (default): Language in query parameter `/pricing?t=fr`
124
+ - Use with standard React Router setup
125
+ - No URL structure changes needed
126
+
127
+ - **`path`**: Language in URL path `/fr/pricing`
128
+ - Use with `<LangRouter>` wrapper
129
+ - Automatic language routing
130
+ - SEO-optimized URLs
131
+ - See [PATH_EXAMPLES.md](./PATH_EXAMPLES.md) for detailed examples
132
+
133
+ ## Path Mode Helpers (v4.2+)
134
+
135
+ ### LangLink - Language-Aware Links
136
+
137
+ ```tsx
138
+ import { LangLink } from '@aixyte/Lovalingo';
139
+
140
+ function Navigation() {
141
+ return (
142
+ <nav>
143
+ {/* Automatically becomes /en/pricing or /fr/pricing */}
144
+ <LangLink to="pricing">Pricing</LangLink>
145
+ <LangLink to="about">About</LangLink>
146
+ </nav>
147
+ );
148
+ }
149
+ ```
150
+
151
+ ### useLang - Get Current Language
152
+
153
+ ```tsx
154
+ import { useLang } from '@aixyte/Lovalingo';
155
+
156
+ function MyComponent() {
157
+ const lang = useLang(); // 'en', 'fr', 'de', etc.
158
+ return <div>Current language: {lang}</div>;
159
+ }
160
+ ```
161
+
162
+ ### useLangNavigate - Programmatic Navigation
163
+
164
+ ```tsx
165
+ import { useLangNavigate } from '@aixyte/Lovalingo';
166
+
167
+ function MyComponent() {
168
+ const navigate = useLangNavigate();
169
+
170
+ const goToPricing = () => {
171
+ navigate('pricing'); // Goes to /en/pricing or /fr/pricing automatically
172
+ };
173
+
174
+ return <button onClick={goToPricing}>View Pricing</button>;
175
+ }
176
+ ```
177
+
178
+ ## Core Hooks
179
+
180
+ ### useLovalingo
181
+
182
+ Access locale state and switching:
183
+
184
+ ```tsx
185
+ import { useLovalingo } from '@aixyte/Lovalingo';
186
+
187
+ function MyComponent() {
188
+ const { locale, setLocale, isLoading, config } = useLovalingo();
189
+
190
+ return (
191
+ <button onClick={() => setLocale('de')}>
192
+ Switch to German
193
+ </button>
194
+ );
195
+ }
196
+ ```
197
+
198
+ ### useLovalingoTranslate
199
+
200
+ Manual translation control:
201
+
202
+ ```tsx
203
+ import { useLovalingoTranslate } from '@aixyte/Lovalingo';
204
+
205
+ function MyComponent() {
206
+ const { translateElement, translateDOM } = useLovalingoTranslate();
207
+
208
+ const handleDynamicContent = () => {
209
+ // Translate specific element
210
+ const el = document.getElementById('dynamic-content');
211
+ if (el) translateElement(el);
212
+
213
+ // Or translate entire DOM
214
+ translateDOM();
215
+ };
216
+
217
+ return <button onClick={handleDynamicContent}>Load Content</button>;
218
+ }
219
+ ```
220
+
221
+ ### useLovalingoEdit
222
+
223
+ Edit mode for excluding elements:
224
+
225
+ ```tsx
226
+ import { useLovalingoEdit } from '@aixyte/Lovalingo';
227
+
228
+ function MyComponent() {
229
+ const { editMode, toggleEditMode, excludeElement } = useLovalingoEdit();
230
+
231
+ return (
232
+ <button onClick={toggleEditMode}>
233
+ {editMode ? 'Exit Edit Mode' : 'Edit Exclusions'}
234
+ </button>
235
+ );
236
+ }
237
+ ```
238
+
239
+ ## Features
240
+
241
+ - ✅ Zero-flash translations (rendered before browser paint)
242
+ - ✅ Automatic route change detection
243
+ - ✅ MutationObserver for dynamic content
244
+ - ✅ Customizable language switcher
245
+ - ✅ TypeScript support
246
+ - ✅ Works with React Router and Next.js
247
+ - ✅ Edit mode for managing exclusions
248
+ - ✅ Automatic translation miss detection
249
+ - ✅ **Automatic multilingual sitemap generation (v4.2.2+)**
250
+
251
+ ## Automatic Sitemap (v4.2.2+)
252
+
253
+ Your multilingual sitemap is **automatically generated** with zero configuration. Just install `@aixyte/Lovalingo` and it works!
254
+
255
+ ### Zero Configuration
256
+
257
+ ```tsx
258
+ <LovalingoProvider
259
+ apiKey="aix_xxx"
260
+ defaultLocale="en"
261
+ locales={['en', 'de', 'fr', 'es']}
262
+ >
263
+ <App />
264
+ </LovalingoProvider>
265
+
266
+ // ✅ That's it! Sitemap exists automatically at:
267
+ // https://mvbumiwzjytmxswfjgzn.supabase.co/functions/v1/generate-sitemap/aix_xxx
268
+ ```
269
+
270
+ ### Features
271
+
272
+ - ✅ **Auto-discovery**: Pages automatically added as visitors browse
273
+ - ✅ **Multilingual**: All language variants included
274
+ - ✅ **SEO-optimized**: Proper hreflang tags for all locales
275
+ - ✅ **Always up-to-date**: No manual regeneration needed
276
+ - ✅ **Cached**: 1-hour cache for performance
277
+ - ✅ **Zero maintenance**: Completely automatic
278
+
279
+ ### How It Works
280
+
281
+ 1. **Page tracking**: LovalingoProvider tracks every visited page
282
+ 2. **Link injection**: `<link rel="sitemap">` tag automatically added to `<head>`
283
+ 3. **XML generation**: Edge function generates sitemap from discovered pages
284
+ 4. **Google discovers**: Search engines find sitemap via link tag
285
+
286
+ ### Disable Sitemap (Optional)
287
+
288
+ ```tsx
289
+ <LovalingoProvider
290
+ apiKey="aix_xxx"
291
+ defaultLocale="en"
292
+ locales={['en', 'de', 'fr']}
293
+ sitemap={false} // Disable automatic sitemap
294
+ >
295
+ <App />
296
+ </LovalingoProvider>
297
+ ```
298
+
299
+ ### Serve from Your Domain (Optional)
300
+
301
+ #### Netlify
302
+
303
+ ```toml
304
+ # netlify.toml
305
+ [[redirects]]
306
+ from = "/sitemap.xml"
307
+ to = "https://mvbumiwzjytmxswfjgzn.supabase.co/functions/v1/generate-sitemap/YOUR_API_KEY"
308
+ status = 200
309
+ ```
310
+
311
+ #### Vercel
312
+
313
+ ```json
314
+ {
315
+ "rewrites": [{
316
+ "source": "/sitemap.xml",
317
+ "destination": "https://mvbumiwzjytmxswfjgzn.supabase.co/functions/v1/generate-sitemap/YOUR_API_KEY"
318
+ }]
319
+ }
320
+ ```
321
+
322
+ #### Next.js
323
+
324
+ ```tsx
325
+ // app/sitemap.xml/route.ts
326
+ export async function GET() {
327
+ const res = await fetch(
328
+ 'https://mvbumiwzjytmxswfjgzn.supabase.co/functions/v1/generate-sitemap/YOUR_API_KEY'
329
+ );
330
+ return new Response(await res.text(), {
331
+ headers: { 'Content-Type': 'application/xml' }
332
+ });
333
+ }
334
+ ```
335
+
336
+ ## How It Works
337
+
338
+ 1. **Wrap your app** with `<LovalingoProvider>`
339
+ 2. **Locale detection** from URL path or query params
340
+ 3. **Translations loaded** from Lovalingo API
341
+ 4. **DOM translated** before React paints
342
+ 5. **MutationObserver** catches dynamic content
343
+ 6. **Language switcher** appears for easy switching
344
+
345
+ ## License
346
+
347
+ **COMMERCIAL LICENSE - NOT OPEN SOURCE**
348
+
349
+ Copyright (c) 2025 Mertens Advies. All rights reserved.
350
+
351
+ ### For Agencies & Developers
352
+
353
+ ✅ **You MAY:**
354
+ - Use Lovalingo in unlimited client projects
355
+ - Charge clients for integration and development services
356
+ - Deploy compiled code to client applications
357
+ - Install via npm/yarn for development and production
358
+
359
+ ❌ **You MAY NOT:**
360
+ - Resell or white-label Lovalingo as your own product
361
+ - Redistribute source code or allow client modifications
362
+ - Build competing translation products
363
+ - Extract code for other purposes
364
+
365
+ ### For End Clients
366
+
367
+ End clients receive usage rights through their agency/developer and may operate
368
+ applications containing Lovalingo, but may not modify, redistribute, or extract the software.
369
+
370
+ ### License
371
+
372
+ This software is licensed under the **Lovalingo Commercial License**.
373
+ This is NOT open source software. All intellectual property rights remain the
374
+ exclusive property of Mertens Advies.
375
+
376
+ See LICENSE file for complete terms and conditions.
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { LovalingoConfig } from '../types';
3
+ interface LovalingoProviderProps extends LovalingoConfig {
4
+ children: React.ReactNode;
5
+ sitemap?: boolean;
6
+ navigateRef?: React.MutableRefObject<((path: string) => void) | undefined>;
7
+ }
8
+ export declare const LovalingoProvider: React.FC<LovalingoProviderProps>;
9
+ export {};