@qhr123/sa2kit 0.2.0 → 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.
package/README.md CHANGED
@@ -14,6 +14,8 @@ A modern, type-safe React utility library with cross-platform support for buildi
14
14
  - ðŸ’ū **Storage Adapters** - Universal storage abstraction
15
15
  - 📁 **File Upload** - Complete file management with progress tracking
16
16
  - 📊 **Data Export** - Flexible export to CSV, Excel, JSON formats
17
+ - 🌍 **i18n** - Complete internationalization solution
18
+ - 📈 **Analytics** - Comprehensive event tracking and analytics
17
19
 
18
20
  ## Installation
19
21
 
@@ -146,6 +148,84 @@ const exportData = async () => {
146
148
  };
147
149
  ```
148
150
 
151
+ ### Internationalization (i18n)
152
+
153
+ ```typescript
154
+ import { createI18n, useTranslation } from '@qhr123/sa2kit/i18n';
155
+ import { zhCN, enUS } from '@qhr123/sa2kit/i18n';
156
+
157
+ // Create i18n instance
158
+ const i18n = createI18n({
159
+ locale: 'zh-CN',
160
+ fallbackLocale: 'en-US',
161
+ resources: {
162
+ 'zh-CN': zhCN,
163
+ 'en-US': enUS,
164
+ },
165
+ });
166
+
167
+ // In React component
168
+ function MyComponent() {
169
+ const { t, locale, setLocale } = useTranslation();
170
+
171
+ return (
172
+ <div>
173
+ <p>{t('common.welcome')}</p>
174
+ <button onClick={() => setLocale('en-US')}>
175
+ Switch to English
176
+ </button>
177
+ </div>
178
+ );
179
+ }
180
+ ```
181
+
182
+ ### Analytics
183
+
184
+ ```typescript
185
+ import { Analytics, createAnalytics } from '@qhr123/sa2kit/analytics';
186
+
187
+ // Create analytics instance (需čĶæäū›é€‚配å™Ļ)
188
+ const analytics = createAnalytics('my-app', {
189
+ appId: 'my-app',
190
+ appVersion: '1.0.0',
191
+ endpoint: '/api/analytics/events',
192
+ platform: 'web',
193
+ adapter: yourPlatformAdapter, // 需čĶč‡ŠčĄŒåŪžįŽ°
194
+ });
195
+
196
+ // Track events
197
+ analytics.trackEvent('button_click', {
198
+ button_id: 'submit',
199
+ page: 'home',
200
+ });
201
+
202
+ // Use decorators (TypeScript)
203
+ class MyService {
204
+ @Track('user_login')
205
+ async login(username: string) {
206
+ // Login logic
207
+ }
208
+
209
+ @CatchError()
210
+ async fetchData() {
211
+ // Fetch logic
212
+ }
213
+ }
214
+
215
+ // Use React Hooks
216
+ function MyComponent() {
217
+ const trackEvent = useAnalyticsEvent(analytics);
218
+
219
+ usePageView(analytics); // Auto track page views
220
+
221
+ const handleClick = () => {
222
+ trackEvent('button_click', { action: 'submit' });
223
+ };
224
+
225
+ return <button onClick={handleClick}>Submit</button>;
226
+ }
227
+ ```
228
+
149
229
  ## Documentation
150
230
 
151
231
  - [Logger Documentation](./docs/logger.md)
@@ -154,6 +234,8 @@ const exportData = async () => {
154
234
  - [Storage Adapters](./docs/storage.md)
155
235
  - [File Upload Service](./docs/universalFile.md)
156
236
  - [Data Export Service](./docs/universalExport.md)
237
+ - [i18n Internationalization](./docs/i18n.md)
238
+ - [Analytics Tracking](./docs/analytics.md)
157
239
 
158
240
  ## Examples
159
241