experimental-ciao-react 1.0.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 ADDED
@@ -0,0 +1,63 @@
1
+ # @ciao-tools/react
2
+
3
+ React hooks and components for Ciao Tools translations.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @ciao-tools/react
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```tsx
14
+ import { useCt, CTProvider, LanguageSwitcher } from "@ciao-tools/react";
15
+ import manifest from "./ciao-manifest.json";
16
+
17
+ function App() {
18
+ return (
19
+ <CTProvider manifest={manifest}>
20
+ <LanguageSwitcher />
21
+ <Content />
22
+ </CTProvider>
23
+ );
24
+ }
25
+
26
+ function Content() {
27
+ const ct = useCt();
28
+ return <h1>{ct("Hello, world!")}</h1>;
29
+ }
30
+ ```
31
+
32
+ ## Exports
33
+
34
+ ### Hooks
35
+
36
+ - `useCt()` - Returns the translation function
37
+ - `useLanguage()` - Language state and controls
38
+ - `useCurrentLanguage()` - Current language code
39
+ - `useSetLanguage()` - Function to change language
40
+ - `useAvailableLanguages()` - List of available languages
41
+ - `useIsLoading()` - Loading state
42
+ - `useIsReady()` - Ready state
43
+
44
+ ### Components
45
+
46
+ - `CTProvider` - Translation provider with CDN loading
47
+ - `CTContextBlock` - Group related strings for context
48
+ - `Trans` - Translate JSX with nested elements
49
+ - `LanguageSwitcher` - Language selection UI
50
+
51
+ ### Utilities
52
+
53
+ - `interpolate()` - String interpolation with formatting
54
+ - `getLanguageInfo()` - Get language metadata
55
+ - `LANGUAGE_DATA` - Language names, native names, and flags
56
+
57
+ ## Documentation
58
+
59
+ See [docs.ciao-tools.com/react](https://docs.ciao-tools.com/react) for full documentation.
60
+
61
+ ## License
62
+
63
+ MIT