@shopplus/membership-i18n 0.2.0 → 0.2.1

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 (2) hide show
  1. package/README.md +102 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # @shopplus/membership-i18n
2
+
3
+ Shared internationalization package for ShopPlus Membership SDK. 12 locales, Intl-based formatting, RTL support.
4
+
5
+ ## Features
6
+
7
+ - 12 built-in locales: en-US, zh-CN, zh-TW, ja-JP, ko-KR, fr-FR, de-DE, es-ES, pt-BR, th-TH, ar-SA, he-IL
8
+ - 106 error code translations per locale
9
+ - UI component text translations
10
+ - Currency, number, and date formatting via `Intl` APIs
11
+ - RTL detection (Arabic, Hebrew)
12
+ - Lazy-loaded locale chunks (only loaded locale is bundled)
13
+ - Zero runtime dependencies
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ npm install @shopplus/membership-i18n
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```typescript
24
+ import { createI18n } from '@shopplus/membership-i18n';
25
+
26
+ const i18n = await createI18n('zh-CN');
27
+
28
+ // Translate a key
29
+ i18n.t('common.points'); // "积分"
30
+ i18n.t('points.earn', { amount: 100 }); // "获得 100 积分"
31
+
32
+ // Error code translation
33
+ i18n.t('sdk.error.210922'); // "验证码发送过于频繁,请稍后再试"
34
+ ```
35
+
36
+ ## Formatting
37
+
38
+ ```typescript
39
+ import { formatCurrency, formatNumber, formatDate } from '@shopplus/membership-i18n';
40
+
41
+ // Currency (uses Intl.NumberFormat)
42
+ formatCurrency(99.5, 'USD', 'en-US'); // "$99.50"
43
+ formatCurrency(1280, 'JPY', 'ja-JP'); // "¥1,280"
44
+
45
+ // Number
46
+ formatNumber(12345.6, 'de-DE'); // "12.345,6"
47
+
48
+ // Date (uses Intl.DateTimeFormat)
49
+ formatDate(new Date(), 'zh-CN'); // "2026年7月1日"
50
+ ```
51
+
52
+ ## RTL Support
53
+
54
+ ```typescript
55
+ import { isRTL } from '@shopplus/membership-i18n';
56
+
57
+ isRTL('ar-SA'); // true
58
+ isRTL('he-IL'); // true
59
+ isRTL('en-US'); // false
60
+ ```
61
+
62
+ ## Available Locales
63
+
64
+ | Locale | Language | Direction |
65
+ |---|---|---|
66
+ | `en-US` | English | LTR |
67
+ | `zh-CN` | Simplified Chinese | LTR |
68
+ | `zh-TW` | Traditional Chinese | LTR |
69
+ | `ja-JP` | Japanese | LTR |
70
+ | `ko-KR` | Korean | LTR |
71
+ | `fr-FR` | French | LTR |
72
+ | `de-DE` | German | LTR |
73
+ | `es-ES` | Spanish | LTR |
74
+ | `pt-BR` | Brazilian Portuguese | LTR |
75
+ | `th-TH` | Thai | LTR |
76
+ | `ar-SA` | Arabic | RTL |
77
+ | `he-IL` | Hebrew | RTL |
78
+
79
+ ## Translation Keys
80
+
81
+ | Namespace | Description |
82
+ |---|---|
83
+ | `common.*` | Shared UI text (confirm, cancel, loading...) |
84
+ | `points.*` | Points-related messages |
85
+ | `level.*` | Level/tier messages |
86
+ | `coupon.*` | Coupon status text |
87
+ | `checkin.*` | Check-in messages |
88
+ | `errors.*` | Generic error messages |
89
+ | `ui.*` | UI component text (member center, forms, etc.) |
90
+ | `sdk.error.*` | Error code translations (106 codes) |
91
+
92
+ ## Module Formats
93
+
94
+ | Format | File | Usage |
95
+ |---|---|---|
96
+ | ESM | `dist/index.es.js` | Bundlers (locale chunks lazy-loaded) |
97
+ | UMD | `dist/index.umd.js` | Script tag (all locales bundled) |
98
+ | Types | `dist/index.d.ts` | TypeScript support |
99
+
100
+ ## License
101
+
102
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopplus/membership-i18n",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "会员中台共享国际化 - 12 种语言包 + Intl 格式化函数 + RTL 支持",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.js",