@lovalingo/lovalingo 0.4.0 → 0.5.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 CHANGED
@@ -43,61 +43,58 @@ You can override it (advanced):
43
43
 
44
44
  ## React Router
45
45
 
46
- ### Query mode (default)
46
+ ### Path mode (default, recommended)
47
47
 
48
48
  ```tsx
49
- import { BrowserRouter } from "react-router-dom";
49
+ import { useRef } from "react";
50
+ import { Routes, Route } from "react-router-dom";
50
51
  import { LovalingoProvider } from "@lovalingo/lovalingo";
52
+ import { LangRouter } from "@lovalingo/lovalingo";
51
53
 
52
54
  export function App() {
55
+ const navigateRef = useRef();
56
+
53
57
  return (
54
- <BrowserRouter>
58
+ <LangRouter defaultLang="en" langs={["en", "de", "fr"]} navigateRef={navigateRef}>
55
59
  <LovalingoProvider
56
60
  publicAnonKey="aix_your_public_anon_key"
57
61
  defaultLocale="en"
58
62
  locales={["en", "de", "fr"]}
59
- routing="query"
63
+ routing="path"
64
+ navigateRef={navigateRef}
60
65
  >
61
66
  <YourApp />
62
67
  </LovalingoProvider>
63
- </BrowserRouter>
68
+ </LangRouter>
64
69
  );
65
70
  }
66
71
  ```
67
72
 
68
- URLs look like: `/pricing?t=de`.
73
+ URLs look like: `/de/pricing`.
69
74
 
70
- ### Path mode (SEO-friendly URLs)
75
+ ### Query mode (legacy)
71
76
 
72
77
  ```tsx
73
- import { useRef } from "react";
74
- import { Routes, Route } from "react-router-dom";
75
- import { LangRouter, LovalingoProvider } from "@lovalingo/lovalingo";
78
+ import { BrowserRouter } from "react-router-dom";
79
+ import { LovalingoProvider } from "@lovalingo/lovalingo";
76
80
 
77
81
  export function App() {
78
- const navigateRef = useRef<((path: string) => void) | undefined>(undefined);
79
-
80
82
  return (
81
- <LangRouter defaultLang="en" langs={["en", "de", "fr"]} navigateRef={navigateRef}>
83
+ <BrowserRouter>
82
84
  <LovalingoProvider
83
85
  publicAnonKey="aix_your_public_anon_key"
84
86
  defaultLocale="en"
85
87
  locales={["en", "de", "fr"]}
86
- routing="path"
87
- navigateRef={navigateRef}
88
+ routing="query"
88
89
  >
89
- <Routes>
90
- <Route path="/" element={<Home />} />
91
- <Route path="pricing" element={<Pricing />} />
92
- <Route path="about" element={<About />} />
93
- </Routes>
90
+ <YourApp />
94
91
  </LovalingoProvider>
95
- </LangRouter>
92
+ </BrowserRouter>
96
93
  );
97
94
  }
98
95
  ```
99
96
 
100
- URLs look like: `/de/pricing`.
97
+ URLs look like: `/pricing?t=de`.
101
98
 
102
99
  ## Next.js (App Router)
103
100
 
@@ -11,7 +11,7 @@ const LOCALE_STORAGE_KEY = 'Lovalingo_locale';
11
11
  const LOADING_BG_STORAGE_PREFIX = "Lovalingo_loading_bg_color";
12
12
  const BRANDING_STORAGE_PREFIX = "Lovalingo_branding_enabled";
13
13
  const CRITICAL_CACHE_PREFIX = "Lovalingo_critical_v0_3";
14
- export const LovalingoProvider = ({ children, apiKey: apiKeyProp, publicAnonKey, defaultLocale, locales, apiBase = 'https://cdn.lovalingo.com', routing = 'query', // Default to query mode (backward compatible)
14
+ export const LovalingoProvider = ({ children, apiKey: apiKeyProp, publicAnonKey, defaultLocale, locales, apiBase = 'https://cdn.lovalingo.com', routing = 'path', // Default to path mode (SEO-friendly, recommended)
15
15
  autoPrefixLinks = true, autoApplyRules = true, switcherPosition = 'bottom-right', switcherOffsetY = 20, switcherTheme = 'dark', editMode: initialEditMode = false, editKey = 'KeyE', pathNormalization = { enabled: true }, // Enable by default
16
16
  mode = 'dom', // Default to legacy DOM mode for backward compatibility
17
17
  sitemap = true, // Default: true - Auto-inject sitemap link tag
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovalingo/lovalingo",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "React translation runtime with i18n routing, deterministic bundles + DOM rules, and zero-flash rendering.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",