@shopplus/membership-i18n 0.2.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/dist/chunks/ar-SA-DP_snBx2.js +209 -0
- package/dist/chunks/ar-SA-DP_snBx2.js.map +1 -0
- package/dist/chunks/ar-SA-SmRmmy-C.js +178 -0
- package/dist/chunks/ar-SA-SmRmmy-C.js.map +1 -0
- package/dist/chunks/ar-SA-YCCR2p9M.js +286 -0
- package/dist/chunks/ar-SA-YCCR2p9M.js.map +1 -0
- package/dist/chunks/de-DE-2rfmd0jH.js +209 -0
- package/dist/chunks/de-DE-2rfmd0jH.js.map +1 -0
- package/dist/chunks/de-DE-Bg1hwcvH.js +286 -0
- package/dist/chunks/de-DE-Bg1hwcvH.js.map +1 -0
- package/dist/chunks/de-DE-QF5eB9ic.js +178 -0
- package/dist/chunks/de-DE-QF5eB9ic.js.map +1 -0
- package/dist/chunks/en-US-BuxQK5r7.js +178 -0
- package/dist/chunks/en-US-BuxQK5r7.js.map +1 -0
- package/dist/chunks/en-US-BzF4xPel.js +209 -0
- package/dist/chunks/en-US-BzF4xPel.js.map +1 -0
- package/dist/chunks/en-US-CT01P3P9.js +291 -0
- package/dist/chunks/en-US-CT01P3P9.js.map +1 -0
- package/dist/chunks/es-ES-BACY-LxM.js +286 -0
- package/dist/chunks/es-ES-BACY-LxM.js.map +1 -0
- package/dist/chunks/es-ES-BC62zi_S.js +209 -0
- package/dist/chunks/es-ES-BC62zi_S.js.map +1 -0
- package/dist/chunks/es-ES-ChEUG7Kd.js +178 -0
- package/dist/chunks/es-ES-ChEUG7Kd.js.map +1 -0
- package/dist/chunks/fr-FR-CM-doHjn.js +286 -0
- package/dist/chunks/fr-FR-CM-doHjn.js.map +1 -0
- package/dist/chunks/fr-FR-DUoWmG1m.js +209 -0
- package/dist/chunks/fr-FR-DUoWmG1m.js.map +1 -0
- package/dist/chunks/fr-FR-XVBHWWmQ.js +178 -0
- package/dist/chunks/fr-FR-XVBHWWmQ.js.map +1 -0
- package/dist/chunks/he-IL-ChkePFhZ.js +286 -0
- package/dist/chunks/he-IL-ChkePFhZ.js.map +1 -0
- package/dist/chunks/he-IL-DWYROb2e.js +209 -0
- package/dist/chunks/he-IL-DWYROb2e.js.map +1 -0
- package/dist/chunks/he-IL-DoEVi3Vi.js +178 -0
- package/dist/chunks/he-IL-DoEVi3Vi.js.map +1 -0
- package/dist/chunks/ja-JP-B2ugel-u.js +178 -0
- package/dist/chunks/ja-JP-B2ugel-u.js.map +1 -0
- package/dist/chunks/ja-JP-DdBIYhrR.js +286 -0
- package/dist/chunks/ja-JP-DdBIYhrR.js.map +1 -0
- package/dist/chunks/ja-JP-UaYvu-oE.js +209 -0
- package/dist/chunks/ja-JP-UaYvu-oE.js.map +1 -0
- package/dist/chunks/ko-KR-BO83ri35.js +286 -0
- package/dist/chunks/ko-KR-BO83ri35.js.map +1 -0
- package/dist/chunks/ko-KR-Csgr80qJ.js +178 -0
- package/dist/chunks/ko-KR-Csgr80qJ.js.map +1 -0
- package/dist/chunks/ko-KR-QxhuPYWJ.js +209 -0
- package/dist/chunks/ko-KR-QxhuPYWJ.js.map +1 -0
- package/dist/chunks/pt-BR-B7g_XkZG.js +286 -0
- package/dist/chunks/pt-BR-B7g_XkZG.js.map +1 -0
- package/dist/chunks/pt-BR-Bek1YZad.js +178 -0
- package/dist/chunks/pt-BR-Bek1YZad.js.map +1 -0
- package/dist/chunks/pt-BR-KKKjAxDs.js +209 -0
- package/dist/chunks/pt-BR-KKKjAxDs.js.map +1 -0
- package/dist/chunks/th-TH-Coz065G4.js +286 -0
- package/dist/chunks/th-TH-Coz065G4.js.map +1 -0
- package/dist/chunks/th-TH-DLgzYE9r.js +209 -0
- package/dist/chunks/th-TH-DLgzYE9r.js.map +1 -0
- package/dist/chunks/th-TH-DXU76_EA.js +178 -0
- package/dist/chunks/th-TH-DXU76_EA.js.map +1 -0
- package/dist/chunks/zh-CN-CIUcShXd.js +209 -0
- package/dist/chunks/zh-CN-CIUcShXd.js.map +1 -0
- package/dist/chunks/zh-CN-CLJswy78.js +291 -0
- package/dist/chunks/zh-CN-CLJswy78.js.map +1 -0
- package/dist/chunks/zh-CN-DJ7HSPdL.js +178 -0
- package/dist/chunks/zh-CN-DJ7HSPdL.js.map +1 -0
- package/dist/chunks/zh-TW-6MdWLPwV.js +286 -0
- package/dist/chunks/zh-TW-6MdWLPwV.js.map +1 -0
- package/dist/chunks/zh-TW-BkMcexaX.js +178 -0
- package/dist/chunks/zh-TW-BkMcexaX.js.map +1 -0
- package/dist/chunks/zh-TW-mGlSHp00.js +209 -0
- package/dist/chunks/zh-TW-mGlSHp00.js.map +1 -0
- package/dist/format/currency.d.ts +33 -0
- package/dist/format/currency.d.ts.map +1 -0
- package/dist/format/date.d.ts +42 -0
- package/dist/format/date.d.ts.map +1 -0
- package/dist/format/number.d.ts +38 -0
- package/dist/format/number.d.ts.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.es.js +139 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +3 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/rtl.d.ts +14 -0
- package/dist/rtl.d.ts.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
var e = {
|
|
2
|
+
memberCenter: "會員中心",
|
|
3
|
+
points: "積分",
|
|
4
|
+
level: "等級",
|
|
5
|
+
coupons: "優惠券",
|
|
6
|
+
checkin: "簽到",
|
|
7
|
+
history: "歷史記錄",
|
|
8
|
+
balance: "餘額",
|
|
9
|
+
expire: "過期",
|
|
10
|
+
confirm: "確認",
|
|
11
|
+
cancel: "取消",
|
|
12
|
+
loading: "載入中...",
|
|
13
|
+
noData: "暫無資料",
|
|
14
|
+
retry: "重試",
|
|
15
|
+
success: "成功",
|
|
16
|
+
failed: "失敗"
|
|
17
|
+
}, a = {
|
|
18
|
+
earn: "獲得 {amount} 積分",
|
|
19
|
+
spend: "消費 {amount} 積分",
|
|
20
|
+
balance: "目前餘額:{amount} 積分",
|
|
21
|
+
expired: "{amount} 積分已過期",
|
|
22
|
+
estimated: "預估中(待確認入帳)"
|
|
23
|
+
}, t = {
|
|
24
|
+
current: "目前等級:{name}",
|
|
25
|
+
nextLevel: "下一等級:{name}",
|
|
26
|
+
progress: "距下一等級還需 {current}/{target}",
|
|
27
|
+
upgraded: "恭喜!已升級至 {name}"
|
|
28
|
+
}, r = {
|
|
29
|
+
claim: "領取",
|
|
30
|
+
claimed: "已領取",
|
|
31
|
+
expired: "已過期",
|
|
32
|
+
used: "已使用",
|
|
33
|
+
validUntil: "有效期至 {date}"
|
|
34
|
+
}, n = {
|
|
35
|
+
today: "今日簽到",
|
|
36
|
+
done: "已簽到",
|
|
37
|
+
streak: "連續簽到 {days} 天",
|
|
38
|
+
reward: "+{amount} 積分"
|
|
39
|
+
}, i = {
|
|
40
|
+
network: "網路錯誤,請重試",
|
|
41
|
+
unauthorized: "請先登入",
|
|
42
|
+
serverError: "伺服器異常,請稍後再試",
|
|
43
|
+
timeout: "請求逾時"
|
|
44
|
+
}, o = {
|
|
45
|
+
memberCenter: {
|
|
46
|
+
loading: "載入中...",
|
|
47
|
+
avatarAlt: "會員頭像",
|
|
48
|
+
pointsBalance: "我的積分",
|
|
49
|
+
menuLabel: "會員功能導覽",
|
|
50
|
+
menu: {
|
|
51
|
+
pointsDetail: "積分明細",
|
|
52
|
+
levelDetail: "等級權益",
|
|
53
|
+
coupons: "我的優惠券",
|
|
54
|
+
referral: "邀請好友",
|
|
55
|
+
checkin: "每日簽到"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
pointsDetail: {
|
|
59
|
+
title: "積分明細",
|
|
60
|
+
empty: "暫無積分流水",
|
|
61
|
+
loading: "載入中...",
|
|
62
|
+
noMore: "已經到底囉",
|
|
63
|
+
listLabel: "積分流水列表",
|
|
64
|
+
status: {
|
|
65
|
+
pending: "待確認",
|
|
66
|
+
active: "已生效",
|
|
67
|
+
used: "已使用",
|
|
68
|
+
expired: "已過期"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
levelProgress: {
|
|
72
|
+
loading: "載入中...",
|
|
73
|
+
maxLevel: "已是最高等級",
|
|
74
|
+
progressLabel: "等級進度",
|
|
75
|
+
noBenefits: "暫無權益",
|
|
76
|
+
nextLevel: "下一等級:{name}",
|
|
77
|
+
benefitsTitle: "我的權益"
|
|
78
|
+
},
|
|
79
|
+
couponList: {
|
|
80
|
+
title: "我的優惠券",
|
|
81
|
+
tabsLabel: "優惠券分類",
|
|
82
|
+
listLabel: "優惠券列表",
|
|
83
|
+
empty: "暫無優惠券",
|
|
84
|
+
freeShipping: "免運",
|
|
85
|
+
giftValue: "贈品",
|
|
86
|
+
discountValue: "{value} 折",
|
|
87
|
+
type: {
|
|
88
|
+
discount: "折扣券",
|
|
89
|
+
cash: "現金券",
|
|
90
|
+
shipping: "運費券",
|
|
91
|
+
gift: "贈品券"
|
|
92
|
+
},
|
|
93
|
+
tab: {
|
|
94
|
+
available: "可使用",
|
|
95
|
+
used: "已使用",
|
|
96
|
+
expired: "已過期"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
referralShare: {
|
|
100
|
+
loading: "載入中...",
|
|
101
|
+
title: "邀請好友",
|
|
102
|
+
shareTitle: "邀請好友贏積分",
|
|
103
|
+
shareText: "快來加入會員,註冊即送好禮!",
|
|
104
|
+
invitedCount: "已邀請",
|
|
105
|
+
rewardPoints: "已獲積分",
|
|
106
|
+
codeLabel: "我的邀請碼",
|
|
107
|
+
linkLabel: "邀請連結",
|
|
108
|
+
copy: "複製",
|
|
109
|
+
copyCode: "複製邀請碼",
|
|
110
|
+
share: "立即分享",
|
|
111
|
+
rewardHint: "每邀請一位好友獎勵 {points} 積分"
|
|
112
|
+
},
|
|
113
|
+
checkinCalendar: {
|
|
114
|
+
loading: "載入中...",
|
|
115
|
+
checking: "簽到中...",
|
|
116
|
+
checkin: "立即簽到",
|
|
117
|
+
alreadyChecked: "今日已簽到",
|
|
118
|
+
day: "{count} 天",
|
|
119
|
+
title: "每日簽到",
|
|
120
|
+
streak: "連續簽到 {days} 天",
|
|
121
|
+
calendarLabel: "簽到日曆",
|
|
122
|
+
rewardsTitle: "連續簽到獎勵",
|
|
123
|
+
rewardsLabel: "簽到獎勵列表",
|
|
124
|
+
weekday: {
|
|
125
|
+
sun: "日",
|
|
126
|
+
mon: "一",
|
|
127
|
+
tue: "二",
|
|
128
|
+
wed: "三",
|
|
129
|
+
thu: "四",
|
|
130
|
+
fri: "五",
|
|
131
|
+
sat: "六"
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
auth: {
|
|
135
|
+
login: {
|
|
136
|
+
emailLabel: "電子郵件",
|
|
137
|
+
passwordLabel: "密碼",
|
|
138
|
+
submit: "登入",
|
|
139
|
+
createAccount: "建立帳號",
|
|
140
|
+
forgotPassword: "忘記密碼?",
|
|
141
|
+
orDivider: "或"
|
|
142
|
+
},
|
|
143
|
+
register: {
|
|
144
|
+
emailLabel: "電子郵件",
|
|
145
|
+
passwordLabel: "密碼",
|
|
146
|
+
confirmPasswordLabel: "確認密碼",
|
|
147
|
+
passwordHint: "至少 8 個字元,包含字母和數字",
|
|
148
|
+
submit: "建立帳號",
|
|
149
|
+
hasAccount: "已有帳號?立即登入",
|
|
150
|
+
passwordMismatch: "兩次輸入的密碼不一致"
|
|
151
|
+
},
|
|
152
|
+
oauth: { continueWith: "透過 {provider} 繼續" },
|
|
153
|
+
verify: {
|
|
154
|
+
resend: "重新傳送驗證碼",
|
|
155
|
+
resendCountdown: "重新傳送({countdown}秒)"
|
|
156
|
+
},
|
|
157
|
+
forgot: {
|
|
158
|
+
title: "重設密碼",
|
|
159
|
+
description: "輸入您的電子郵件,我們將傳送驗證碼給您。",
|
|
160
|
+
emailLabel: "電子郵件",
|
|
161
|
+
submit: "傳送驗證碼",
|
|
162
|
+
backToLogin: "返回登入"
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}, s = { error: {
|
|
166
|
+
211001: "回呼簽章驗證失敗",
|
|
167
|
+
211003: "回呼請求重複",
|
|
168
|
+
211005: "平台憑證已失效",
|
|
169
|
+
211900: "操作失敗,請稍後重試",
|
|
170
|
+
211903: "請求參數錯誤",
|
|
171
|
+
211909: "請先登入或權杖已失效",
|
|
172
|
+
211910: "無權存取該資源",
|
|
173
|
+
211911: "找不到對應的會員資訊",
|
|
174
|
+
211912: "身份關聯衝突,請聯絡客服",
|
|
175
|
+
211931: "會員等級設定異常",
|
|
176
|
+
211933: "等級權益不可用",
|
|
177
|
+
211951: "積分餘額不足",
|
|
178
|
+
211952: "積分帳目異常,請聯絡客服",
|
|
179
|
+
211955: "積分獲取規則未設定",
|
|
180
|
+
211956: "積分扣除失敗",
|
|
181
|
+
211957: "積分已過期",
|
|
182
|
+
211958: "積分流水衝突,請重試",
|
|
183
|
+
211971: "優惠券不可用",
|
|
184
|
+
211973: "優惠券已被領取",
|
|
185
|
+
211975: "優惠券已過期",
|
|
186
|
+
211976: "優惠券已被使用",
|
|
187
|
+
211991: "服務忙碌,請稍後重試",
|
|
188
|
+
network: "網路異常,請檢查連線後重試",
|
|
189
|
+
timeout: "請求逾時,請稍後重試",
|
|
190
|
+
aborted: "請求已被取消",
|
|
191
|
+
parse: "資料解析異常",
|
|
192
|
+
unauthorized: "請先登入",
|
|
193
|
+
config: "SDK 初始化參數錯誤",
|
|
194
|
+
unknown: "發生未知錯誤,請稍後重試"
|
|
195
|
+
} }, l = {
|
|
196
|
+
common: e,
|
|
197
|
+
points: a,
|
|
198
|
+
level: t,
|
|
199
|
+
coupon: r,
|
|
200
|
+
checkin: n,
|
|
201
|
+
errors: i,
|
|
202
|
+
ui: o,
|
|
203
|
+
sdk: s
|
|
204
|
+
};
|
|
205
|
+
export {
|
|
206
|
+
l as default
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
//# sourceMappingURL=zh-TW-mGlSHp00.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zh-TW-mGlSHp00.js","names":[],"sources":["../../src/locales/zh-TW.json"],"sourcesContent":["{\n \"common\": {\n \"memberCenter\": \"會員中心\",\n \"points\": \"積分\",\n \"level\": \"等級\",\n \"coupons\": \"優惠券\",\n \"checkin\": \"簽到\",\n \"history\": \"歷史記錄\",\n \"balance\": \"餘額\",\n \"expire\": \"過期\",\n \"confirm\": \"確認\",\n \"cancel\": \"取消\",\n \"loading\": \"載入中...\",\n \"noData\": \"暫無資料\",\n \"retry\": \"重試\",\n \"success\": \"成功\",\n \"failed\": \"失敗\"\n },\n \"points\": {\n \"earn\": \"獲得 {amount} 積分\",\n \"spend\": \"消費 {amount} 積分\",\n \"balance\": \"目前餘額:{amount} 積分\",\n \"expired\": \"{amount} 積分已過期\",\n \"estimated\": \"預估中(待確認入帳)\"\n },\n \"level\": {\n \"current\": \"目前等級:{name}\",\n \"nextLevel\": \"下一等級:{name}\",\n \"progress\": \"距下一等級還需 {current}/{target}\",\n \"upgraded\": \"恭喜!已升級至 {name}\"\n },\n \"coupon\": {\n \"claim\": \"領取\",\n \"claimed\": \"已領取\",\n \"expired\": \"已過期\",\n \"used\": \"已使用\",\n \"validUntil\": \"有效期至 {date}\"\n },\n \"checkin\": {\n \"today\": \"今日簽到\",\n \"done\": \"已簽到\",\n \"streak\": \"連續簽到 {days} 天\",\n \"reward\": \"+{amount} 積分\"\n },\n \"errors\": {\n \"network\": \"網路錯誤,請重試\",\n \"unauthorized\": \"請先登入\",\n \"serverError\": \"伺服器異常,請稍後再試\",\n \"timeout\": \"請求逾時\"\n },\n \"ui\": {\n \"memberCenter\": {\n \"loading\": \"載入中...\",\n \"avatarAlt\": \"會員頭像\",\n \"pointsBalance\": \"我的積分\",\n \"menuLabel\": \"會員功能導覽\",\n \"menu\": {\n \"pointsDetail\": \"積分明細\",\n \"levelDetail\": \"等級權益\",\n \"coupons\": \"我的優惠券\",\n \"referral\": \"邀請好友\",\n \"checkin\": \"每日簽到\"\n }\n },\n \"pointsDetail\": {\n \"title\": \"積分明細\",\n \"empty\": \"暫無積分流水\",\n \"loading\": \"載入中...\",\n \"noMore\": \"已經到底囉\",\n \"listLabel\": \"積分流水列表\",\n \"status\": {\n \"pending\": \"待確認\",\n \"active\": \"已生效\",\n \"used\": \"已使用\",\n \"expired\": \"已過期\"\n }\n },\n \"levelProgress\": {\n \"loading\": \"載入中...\",\n \"maxLevel\": \"已是最高等級\",\n \"progressLabel\": \"等級進度\",\n \"noBenefits\": \"暫無權益\",\n \"nextLevel\": \"下一等級:{name}\",\n \"benefitsTitle\": \"我的權益\"\n },\n \"couponList\": {\n \"title\": \"我的優惠券\",\n \"tabsLabel\": \"優惠券分類\",\n \"listLabel\": \"優惠券列表\",\n \"empty\": \"暫無優惠券\",\n \"freeShipping\": \"免運\",\n \"giftValue\": \"贈品\",\n \"discountValue\": \"{value} 折\",\n \"type\": {\n \"discount\": \"折扣券\",\n \"cash\": \"現金券\",\n \"shipping\": \"運費券\",\n \"gift\": \"贈品券\"\n },\n \"tab\": {\n \"available\": \"可使用\",\n \"used\": \"已使用\",\n \"expired\": \"已過期\"\n }\n },\n \"referralShare\": {\n \"loading\": \"載入中...\",\n \"title\": \"邀請好友\",\n \"shareTitle\": \"邀請好友贏積分\",\n \"shareText\": \"快來加入會員,註冊即送好禮!\",\n \"invitedCount\": \"已邀請\",\n \"rewardPoints\": \"已獲積分\",\n \"codeLabel\": \"我的邀請碼\",\n \"linkLabel\": \"邀請連結\",\n \"copy\": \"複製\",\n \"copyCode\": \"複製邀請碼\",\n \"share\": \"立即分享\",\n \"rewardHint\": \"每邀請一位好友獎勵 {points} 積分\"\n },\n \"checkinCalendar\": {\n \"loading\": \"載入中...\",\n \"checking\": \"簽到中...\",\n \"checkin\": \"立即簽到\",\n \"alreadyChecked\": \"今日已簽到\",\n \"day\": \"{count} 天\",\n \"title\": \"每日簽到\",\n \"streak\": \"連續簽到 {days} 天\",\n \"calendarLabel\": \"簽到日曆\",\n \"rewardsTitle\": \"連續簽到獎勵\",\n \"rewardsLabel\": \"簽到獎勵列表\",\n \"weekday\": {\n \"sun\": \"日\",\n \"mon\": \"一\",\n \"tue\": \"二\",\n \"wed\": \"三\",\n \"thu\": \"四\",\n \"fri\": \"五\",\n \"sat\": \"六\"\n }\n },\n \"auth\": {\n \"login\": {\n \"emailLabel\": \"電子郵件\",\n \"passwordLabel\": \"密碼\",\n \"submit\": \"登入\",\n \"createAccount\": \"建立帳號\",\n \"forgotPassword\": \"忘記密碼?\",\n \"orDivider\": \"或\"\n },\n \"register\": {\n \"emailLabel\": \"電子郵件\",\n \"passwordLabel\": \"密碼\",\n \"confirmPasswordLabel\": \"確認密碼\",\n \"passwordHint\": \"至少 8 個字元,包含字母和數字\",\n \"submit\": \"建立帳號\",\n \"hasAccount\": \"已有帳號?立即登入\",\n \"passwordMismatch\": \"兩次輸入的密碼不一致\"\n },\n \"oauth\": {\n \"continueWith\": \"透過 {provider} 繼續\"\n },\n \"verify\": {\n \"resend\": \"重新傳送驗證碼\",\n \"resendCountdown\": \"重新傳送({countdown}秒)\"\n },\n \"forgot\": {\n \"title\": \"重設密碼\",\n \"description\": \"輸入您的電子郵件,我們將傳送驗證碼給您。\",\n \"emailLabel\": \"電子郵件\",\n \"submit\": \"傳送驗證碼\",\n \"backToLogin\": \"返回登入\"\n }\n }\n },\n \"sdk\": {\n \"error\": {\n \"211001\": \"回呼簽章驗證失敗\",\n \"211003\": \"回呼請求重複\",\n \"211005\": \"平台憑證已失效\",\n \"211900\": \"操作失敗,請稍後重試\",\n \"211903\": \"請求參數錯誤\",\n \"211909\": \"請先登入或權杖已失效\",\n \"211910\": \"無權存取該資源\",\n \"211911\": \"找不到對應的會員資訊\",\n \"211912\": \"身份關聯衝突,請聯絡客服\",\n \"211931\": \"會員等級設定異常\",\n \"211933\": \"等級權益不可用\",\n \"211951\": \"積分餘額不足\",\n \"211952\": \"積分帳目異常,請聯絡客服\",\n \"211955\": \"積分獲取規則未設定\",\n \"211956\": \"積分扣除失敗\",\n \"211957\": \"積分已過期\",\n \"211958\": \"積分流水衝突,請重試\",\n \"211971\": \"優惠券不可用\",\n \"211973\": \"優惠券已被領取\",\n \"211975\": \"優惠券已過期\",\n \"211976\": \"優惠券已被使用\",\n \"211991\": \"服務忙碌,請稍後重試\",\n \"network\": \"網路異常,請檢查連線後重試\",\n \"timeout\": \"請求逾時,請稍後重試\",\n \"aborted\": \"請求已被取消\",\n \"parse\": \"資料解析異常\",\n \"unauthorized\": \"請先登入\",\n \"config\": \"SDK 初始化參數錯誤\",\n \"unknown\": \"發生未知錯誤,請稍後重試\"\n }\n }\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 货币格式化 - 基于 Intl.NumberFormat
|
|
3
|
+
*
|
|
4
|
+
* 禁止使用 toFixed,禁止硬编码货币符号
|
|
5
|
+
* 必须接收 currency 参数,由调用方决定币种
|
|
6
|
+
*/
|
|
7
|
+
export interface FormatCurrencyOptions {
|
|
8
|
+
/** ISO 4217 货币代码,如 'USD', 'CNY', 'EUR' */
|
|
9
|
+
currency: string;
|
|
10
|
+
/** BCP 47 语言标签,默认从浏览器读取 */
|
|
11
|
+
locale?: string;
|
|
12
|
+
/** 小数位数(可选,默认由币种决定) */
|
|
13
|
+
minimumFractionDigits?: number;
|
|
14
|
+
maximumFractionDigits?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 格式化货币金额
|
|
18
|
+
*
|
|
19
|
+
* @param amount - 金额数值
|
|
20
|
+
* @param optionsOrCurrency - 格式化选项对象,或直接传 ISO 4217 货币代码字符串
|
|
21
|
+
* @returns 格式化后的货币字符串
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* formatCurrency(1234.5, { currency: 'USD' });
|
|
26
|
+
* // => "$1,234.50"
|
|
27
|
+
*
|
|
28
|
+
* formatCurrency(1234.5, 'CNY');
|
|
29
|
+
* // => "¥1,234.50"
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function formatCurrency(amount: number, optionsOrCurrency: FormatCurrencyOptions | string): string;
|
|
33
|
+
//# sourceMappingURL=currency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../src/format/currency.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,qBAAqB;IACpC,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,qBAAqB,GAAG,MAAM,GAAG,MAAM,CAexG"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 日期格式化 - 基于 Intl.DateTimeFormat
|
|
3
|
+
*
|
|
4
|
+
* 禁止硬编码 'YYYY-MM-DD' 等格式模板
|
|
5
|
+
* 完全依赖 Intl API 做本地化日期展示
|
|
6
|
+
*/
|
|
7
|
+
export interface FormatDateOptions {
|
|
8
|
+
/** BCP 47 语言标签,默认从浏览器读取 */
|
|
9
|
+
locale?: string;
|
|
10
|
+
/** 日期风格:'full' | 'long' | 'medium' | 'short' */
|
|
11
|
+
dateStyle?: 'full' | 'long' | 'medium' | 'short';
|
|
12
|
+
/** 时间风格:'full' | 'long' | 'medium' | 'short' */
|
|
13
|
+
timeStyle?: 'full' | 'long' | 'medium' | 'short';
|
|
14
|
+
/** 时区 */
|
|
15
|
+
timeZone?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 格式化日期
|
|
19
|
+
*
|
|
20
|
+
* @param date - Date 对象或时间戳
|
|
21
|
+
* @param options - 格式化选项
|
|
22
|
+
* @returns 格式化后的日期字符串
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* formatDate(new Date(), { dateStyle: 'medium', locale: 'zh-CN' });
|
|
27
|
+
* // => "2024年3月15日"
|
|
28
|
+
*
|
|
29
|
+
* formatDate(new Date(), { dateStyle: 'short', locale: 'en-US' });
|
|
30
|
+
* // => "3/15/24"
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function formatDate(date: Date | number | string, options?: FormatDateOptions): string;
|
|
34
|
+
/**
|
|
35
|
+
* 格式化相对时间(如 "3 分钟前")
|
|
36
|
+
*
|
|
37
|
+
* @param date - Date 对象或时间戳
|
|
38
|
+
* @param locale - BCP 47 语言标签
|
|
39
|
+
* @returns 相对时间字符串
|
|
40
|
+
*/
|
|
41
|
+
export declare function formatRelativeTime(date: Date | number, locale?: string): string;
|
|
42
|
+
//# sourceMappingURL=date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/format/date.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,iBAAiB;IAChC,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IACjD,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IACjD,SAAS;IACT,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAmB5F;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAoB/E"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 数字格式化 - 基于 Intl.NumberFormat
|
|
3
|
+
*
|
|
4
|
+
* 禁止使用 toFixed
|
|
5
|
+
* 完全依赖 Intl API 做本地化数字展示
|
|
6
|
+
*/
|
|
7
|
+
export interface FormatNumberOptions {
|
|
8
|
+
/** BCP 47 语言标签,默认从浏览器读取 */
|
|
9
|
+
locale?: string;
|
|
10
|
+
/** 最小小数位数 */
|
|
11
|
+
minimumFractionDigits?: number;
|
|
12
|
+
/** 最大小数位数 */
|
|
13
|
+
maximumFractionDigits?: number;
|
|
14
|
+
/** 是否使用分组分隔符(如千位分隔符) */
|
|
15
|
+
useGrouping?: boolean;
|
|
16
|
+
/** 表示法 */
|
|
17
|
+
notation?: 'standard' | 'scientific' | 'engineering' | 'compact';
|
|
18
|
+
/** 紧凑表示法的显示风格 */
|
|
19
|
+
compactDisplay?: 'short' | 'long';
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 格式化数字
|
|
23
|
+
*
|
|
24
|
+
* @param value - 数值
|
|
25
|
+
* @param options - 格式化选项(兼容 Intl.NumberFormatOptions 超集)
|
|
26
|
+
* @returns 格式化后的数字字符串
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* formatNumber(12345.678, { locale: 'zh-CN', maximumFractionDigits: 2 });
|
|
31
|
+
* // => "12,345.68"
|
|
32
|
+
*
|
|
33
|
+
* formatNumber(1234567, { notation: 'compact', locale: 'en-US' });
|
|
34
|
+
* // => "1.2M"
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatNumber(value: number, options?: FormatNumberOptions & Intl.NumberFormatOptions): string;
|
|
38
|
+
//# sourceMappingURL=number.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../src/format/number.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,mBAAmB;IAClC,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa;IACb,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,aAAa;IACb,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,wBAAwB;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU;IACV,QAAQ,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,aAAa,GAAG,SAAS,CAAC;IACjE,iBAAiB;IACjB,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CACnC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAM5G"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @shopplus/membership-i18n 入口
|
|
3
|
+
* 会员中台共享国际化 - 语言包 + 格式化函数 + RTL 支持
|
|
4
|
+
*/
|
|
5
|
+
export { formatCurrency } from './format/currency';
|
|
6
|
+
export type { FormatCurrencyOptions } from './format/currency';
|
|
7
|
+
export { formatDate, formatRelativeTime } from './format/date';
|
|
8
|
+
export type { FormatDateOptions } from './format/date';
|
|
9
|
+
export { formatNumber } from './format/number';
|
|
10
|
+
export type { FormatNumberOptions } from './format/number';
|
|
11
|
+
export { isRtl, getRtlLocales } from './rtl';
|
|
12
|
+
import type zhCN from './locales/zh-CN.json';
|
|
13
|
+
/** 语言包类型(基于 zh-CN 推导) */
|
|
14
|
+
export type LocaleMessages = typeof zhCN;
|
|
15
|
+
/** 支持的语言(12 种 = PRD §10.3 双 CN + 主流欧美亚 + 阿拉伯/希伯来 RTL + LATAM 葡 + 泰) */
|
|
16
|
+
export type SupportedLocale = 'zh-CN' | 'zh-TW' | 'en-US' | 'ja-JP' | 'ko-KR' | 'fr-FR' | 'de-DE' | 'es-ES' | 'pt-BR' | 'ar-SA' | 'he-IL' | 'th-TH';
|
|
17
|
+
/** 翻译函数参数 */
|
|
18
|
+
export interface TranslateParams {
|
|
19
|
+
[key: string]: string | number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 注册语言包
|
|
23
|
+
*/
|
|
24
|
+
export declare function registerLocale(locale: string, messages: LocaleMessages): void;
|
|
25
|
+
/**
|
|
26
|
+
* 设置当前语言
|
|
27
|
+
*/
|
|
28
|
+
export declare function setLocale(locale: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* 获取当前语言
|
|
31
|
+
*/
|
|
32
|
+
export declare function getLocale(): string;
|
|
33
|
+
/**
|
|
34
|
+
* 翻译函数
|
|
35
|
+
* 支持插值:t('points.earn', { amount: 100 }) => "获得 100 积分"
|
|
36
|
+
*
|
|
37
|
+
* @param key - 翻译键(点分隔,如 'common.points')
|
|
38
|
+
* @param params - 插值参数
|
|
39
|
+
* @returns 翻译后的文本
|
|
40
|
+
*/
|
|
41
|
+
export declare function t(key: string, params?: TranslateParams): string;
|
|
42
|
+
/**
|
|
43
|
+
* 初始化内置语言包
|
|
44
|
+
* 延迟加载,避免打包体积过大
|
|
45
|
+
*/
|
|
46
|
+
export declare function loadBuiltinLocale(locale: SupportedLocale): Promise<void>;
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC/D,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAG3D,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG7C,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAE7C,yBAAyB;AACzB,MAAM,MAAM,cAAc,GAAG,OAAO,IAAI,CAAC;AAEzC,uEAAuE;AACvE,MAAM,MAAM,eAAe,GACvB,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,CAAC;AAEZ,aAAa;AACb,MAAM,WAAW,eAAe;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CAChC;AAQD;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,IAAI,CAE7E;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED;;;;;;;GAOG;AACH,wBAAgB,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,MAAM,CAwB/D;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA8C9E"}
|
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
function g(t, e) {
|
|
2
|
+
const { currency: a, locale: r, minimumFractionDigits: n, maximumFractionDigits: o } = typeof e == "string" ? { currency: e } : e;
|
|
3
|
+
return new Intl.NumberFormat(r, {
|
|
4
|
+
style: "currency",
|
|
5
|
+
currency: a,
|
|
6
|
+
minimumFractionDigits: n,
|
|
7
|
+
maximumFractionDigits: o
|
|
8
|
+
}).format(t);
|
|
9
|
+
}
|
|
10
|
+
function y(t, e) {
|
|
11
|
+
const { locale: a, dateStyle: r, timeStyle: n, timeZone: o } = e != null ? e : {}, u = new Intl.DateTimeFormat(a, {
|
|
12
|
+
dateStyle: r != null ? r : "medium",
|
|
13
|
+
timeStyle: n,
|
|
14
|
+
timeZone: o
|
|
15
|
+
});
|
|
16
|
+
let i;
|
|
17
|
+
return typeof t == "string" ? i = new Date(t) : typeof t == "number" ? i = new Date(t) : i = t, u.format(i);
|
|
18
|
+
}
|
|
19
|
+
function v(t, e) {
|
|
20
|
+
const a = typeof t == "number" ? new Date(t) : t, r = Date.now(), n = a.getTime() - r, o = Math.round(n / 1e3), u = Math.round(o / 60), i = Math.round(u / 60), m = Math.round(i / 24), f = new Intl.RelativeTimeFormat(e, { numeric: "auto" });
|
|
21
|
+
return Math.abs(o) < 60 ? f.format(o, "second") : Math.abs(u) < 60 ? f.format(u, "minute") : Math.abs(i) < 24 ? f.format(i, "hour") : f.format(m, "day");
|
|
22
|
+
}
|
|
23
|
+
function d(t, e) {
|
|
24
|
+
if (t == null) return {};
|
|
25
|
+
var a = {};
|
|
26
|
+
for (var r in t) if ({}.hasOwnProperty.call(t, r)) {
|
|
27
|
+
if (e.includes(r)) continue;
|
|
28
|
+
a[r] = t[r];
|
|
29
|
+
}
|
|
30
|
+
return a;
|
|
31
|
+
}
|
|
32
|
+
function b(t, e) {
|
|
33
|
+
if (t == null) return {};
|
|
34
|
+
var a, r, n = d(t, e);
|
|
35
|
+
if (Object.getOwnPropertySymbols) {
|
|
36
|
+
var o = Object.getOwnPropertySymbols(t);
|
|
37
|
+
for (r = 0; r < o.length; r++) a = o[r], e.includes(a) || {}.propertyIsEnumerable.call(t, a) && (n[a] = t[a]);
|
|
38
|
+
}
|
|
39
|
+
return n;
|
|
40
|
+
}
|
|
41
|
+
var w = ["locale"];
|
|
42
|
+
function S(t, e) {
|
|
43
|
+
const a = e != null ? e : {}, { locale: r } = a, n = b(a, w);
|
|
44
|
+
return new Intl.NumberFormat(r, n).format(t);
|
|
45
|
+
}
|
|
46
|
+
var l = /* @__PURE__ */ new Set([
|
|
47
|
+
"ar-SA",
|
|
48
|
+
"he-IL",
|
|
49
|
+
"fa-IR"
|
|
50
|
+
]);
|
|
51
|
+
function L(t) {
|
|
52
|
+
return l.has(t);
|
|
53
|
+
}
|
|
54
|
+
function M() {
|
|
55
|
+
return [...l];
|
|
56
|
+
}
|
|
57
|
+
var s = /* @__PURE__ */ new Map(), c = "zh-CN";
|
|
58
|
+
function p(t, e) {
|
|
59
|
+
s.set(t, e);
|
|
60
|
+
}
|
|
61
|
+
function h(t) {
|
|
62
|
+
c = t;
|
|
63
|
+
}
|
|
64
|
+
function k() {
|
|
65
|
+
return c;
|
|
66
|
+
}
|
|
67
|
+
function D(t, e) {
|
|
68
|
+
const a = s.get(c);
|
|
69
|
+
if (!a) return t;
|
|
70
|
+
const r = t.split(".");
|
|
71
|
+
let n = a;
|
|
72
|
+
for (const o of r) {
|
|
73
|
+
if (n == null || typeof n != "object") return t;
|
|
74
|
+
n = n[o];
|
|
75
|
+
}
|
|
76
|
+
return typeof n != "string" ? t : e ? n.replace(/\{(\w+)\}/g, (o, u) => {
|
|
77
|
+
const i = e[u];
|
|
78
|
+
return i !== void 0 ? String(i) : `{${u}}`;
|
|
79
|
+
}) : n;
|
|
80
|
+
}
|
|
81
|
+
async function R(t) {
|
|
82
|
+
let e;
|
|
83
|
+
switch (t) {
|
|
84
|
+
case "zh-CN":
|
|
85
|
+
e = (await import("./chunks/zh-CN-CLJswy78.js")).default;
|
|
86
|
+
break;
|
|
87
|
+
case "zh-TW":
|
|
88
|
+
e = (await import("./chunks/zh-TW-6MdWLPwV.js")).default;
|
|
89
|
+
break;
|
|
90
|
+
case "en-US":
|
|
91
|
+
e = (await import("./chunks/en-US-CT01P3P9.js")).default;
|
|
92
|
+
break;
|
|
93
|
+
case "ja-JP":
|
|
94
|
+
e = (await import("./chunks/ja-JP-DdBIYhrR.js")).default;
|
|
95
|
+
break;
|
|
96
|
+
case "ko-KR":
|
|
97
|
+
e = (await import("./chunks/ko-KR-BO83ri35.js")).default;
|
|
98
|
+
break;
|
|
99
|
+
case "fr-FR":
|
|
100
|
+
e = (await import("./chunks/fr-FR-CM-doHjn.js")).default;
|
|
101
|
+
break;
|
|
102
|
+
case "de-DE":
|
|
103
|
+
e = (await import("./chunks/de-DE-Bg1hwcvH.js")).default;
|
|
104
|
+
break;
|
|
105
|
+
case "es-ES":
|
|
106
|
+
e = (await import("./chunks/es-ES-BACY-LxM.js")).default;
|
|
107
|
+
break;
|
|
108
|
+
case "pt-BR":
|
|
109
|
+
e = (await import("./chunks/pt-BR-B7g_XkZG.js")).default;
|
|
110
|
+
break;
|
|
111
|
+
case "ar-SA":
|
|
112
|
+
e = (await import("./chunks/ar-SA-YCCR2p9M.js")).default;
|
|
113
|
+
break;
|
|
114
|
+
case "he-IL":
|
|
115
|
+
e = (await import("./chunks/he-IL-ChkePFhZ.js")).default;
|
|
116
|
+
break;
|
|
117
|
+
case "th-TH":
|
|
118
|
+
e = (await import("./chunks/th-TH-Coz065G4.js")).default;
|
|
119
|
+
break;
|
|
120
|
+
default:
|
|
121
|
+
throw new Error(`Unsupported locale: ${t}`);
|
|
122
|
+
}
|
|
123
|
+
p(t, e), h(t);
|
|
124
|
+
}
|
|
125
|
+
export {
|
|
126
|
+
g as formatCurrency,
|
|
127
|
+
y as formatDate,
|
|
128
|
+
S as formatNumber,
|
|
129
|
+
v as formatRelativeTime,
|
|
130
|
+
k as getLocale,
|
|
131
|
+
M as getRtlLocales,
|
|
132
|
+
L as isRtl,
|
|
133
|
+
R as loadBuiltinLocale,
|
|
134
|
+
p as registerLocale,
|
|
135
|
+
h as setLocale,
|
|
136
|
+
D as t
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
//# sourceMappingURL=index.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.es.js","names":[],"sources":["../src/format/currency.ts","../src/format/date.ts","../src/format/number.ts","../src/rtl.ts","../src/index.ts"],"sourcesContent":["/**\n * 货币格式化 - 基于 Intl.NumberFormat\n *\n * 禁止使用 toFixed,禁止硬编码货币符号\n * 必须接收 currency 参数,由调用方决定币种\n */\n\nexport interface FormatCurrencyOptions {\n /** ISO 4217 货币代码,如 'USD', 'CNY', 'EUR' */\n currency: string;\n /** BCP 47 语言标签,默认从浏览器读取 */\n locale?: string;\n /** 小数位数(可选,默认由币种决定) */\n minimumFractionDigits?: number;\n maximumFractionDigits?: number;\n}\n\n/**\n * 格式化货币金额\n *\n * @param amount - 金额数值\n * @param optionsOrCurrency - 格式化选项对象,或直接传 ISO 4217 货币代码字符串\n * @returns 格式化后的货币字符串\n *\n * @example\n * ```typescript\n * formatCurrency(1234.5, { currency: 'USD' });\n * // => \"$1,234.50\"\n *\n * formatCurrency(1234.5, 'CNY');\n * // => \"¥1,234.50\"\n * ```\n */\nexport function formatCurrency(amount: number, optionsOrCurrency: FormatCurrencyOptions | string): string {\n const options: FormatCurrencyOptions = typeof optionsOrCurrency === 'string'\n ? { currency: optionsOrCurrency }\n : optionsOrCurrency;\n\n const { currency, locale, minimumFractionDigits, maximumFractionDigits } = options;\n\n const formatter = new Intl.NumberFormat(locale, {\n style: 'currency',\n currency,\n minimumFractionDigits,\n maximumFractionDigits,\n });\n\n return formatter.format(amount);\n}\n","/**\n * 日期格式化 - 基于 Intl.DateTimeFormat\n *\n * 禁止硬编码 'YYYY-MM-DD' 等格式模板\n * 完全依赖 Intl API 做本地化日期展示\n */\n\nexport interface FormatDateOptions {\n /** BCP 47 语言标签,默认从浏览器读取 */\n locale?: string;\n /** 日期风格:'full' | 'long' | 'medium' | 'short' */\n dateStyle?: 'full' | 'long' | 'medium' | 'short';\n /** 时间风格:'full' | 'long' | 'medium' | 'short' */\n timeStyle?: 'full' | 'long' | 'medium' | 'short';\n /** 时区 */\n timeZone?: string;\n}\n\n/**\n * 格式化日期\n *\n * @param date - Date 对象或时间戳\n * @param options - 格式化选项\n * @returns 格式化后的日期字符串\n *\n * @example\n * ```typescript\n * formatDate(new Date(), { dateStyle: 'medium', locale: 'zh-CN' });\n * // => \"2024年3月15日\"\n *\n * formatDate(new Date(), { dateStyle: 'short', locale: 'en-US' });\n * // => \"3/15/24\"\n * ```\n */\nexport function formatDate(date: Date | number | string, options?: FormatDateOptions): string {\n const { locale, dateStyle, timeStyle, timeZone } = options ?? {};\n\n const formatter = new Intl.DateTimeFormat(locale, {\n dateStyle: dateStyle ?? 'medium',\n timeStyle,\n timeZone,\n });\n\n let dateObj: Date;\n if (typeof date === 'string') {\n dateObj = new Date(date);\n } else if (typeof date === 'number') {\n dateObj = new Date(date);\n } else {\n dateObj = date;\n }\n\n return formatter.format(dateObj);\n}\n\n/**\n * 格式化相对时间(如 \"3 分钟前\")\n *\n * @param date - Date 对象或时间戳\n * @param locale - BCP 47 语言标签\n * @returns 相对时间字符串\n */\nexport function formatRelativeTime(date: Date | number, locale?: string): string {\n const dateObj = typeof date === 'number' ? new Date(date) : date;\n const now = Date.now();\n const diffMs = dateObj.getTime() - now;\n const diffSec = Math.round(diffMs / 1000);\n const diffMin = Math.round(diffSec / 60);\n const diffHour = Math.round(diffMin / 60);\n const diffDay = Math.round(diffHour / 24);\n\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });\n\n if (Math.abs(diffSec) < 60) {\n return rtf.format(diffSec, 'second');\n } else if (Math.abs(diffMin) < 60) {\n return rtf.format(diffMin, 'minute');\n } else if (Math.abs(diffHour) < 24) {\n return rtf.format(diffHour, 'hour');\n } else {\n return rtf.format(diffDay, 'day');\n }\n}\n","/**\n * 数字格式化 - 基于 Intl.NumberFormat\n *\n * 禁止使用 toFixed\n * 完全依赖 Intl API 做本地化数字展示\n */\n\nexport interface FormatNumberOptions {\n /** BCP 47 语言标签,默认从浏览器读取 */\n locale?: string;\n /** 最小小数位数 */\n minimumFractionDigits?: number;\n /** 最大小数位数 */\n maximumFractionDigits?: number;\n /** 是否使用分组分隔符(如千位分隔符) */\n useGrouping?: boolean;\n /** 表示法 */\n notation?: 'standard' | 'scientific' | 'engineering' | 'compact';\n /** 紧凑表示法的显示风格 */\n compactDisplay?: 'short' | 'long';\n}\n\n/**\n * 格式化数字\n *\n * @param value - 数值\n * @param options - 格式化选项(兼容 Intl.NumberFormatOptions 超集)\n * @returns 格式化后的数字字符串\n *\n * @example\n * ```typescript\n * formatNumber(12345.678, { locale: 'zh-CN', maximumFractionDigits: 2 });\n * // => \"12,345.68\"\n *\n * formatNumber(1234567, { notation: 'compact', locale: 'en-US' });\n * // => \"1.2M\"\n * ```\n */\nexport function formatNumber(value: number, options?: FormatNumberOptions & Intl.NumberFormatOptions): string {\n const { locale, ...intlOptions } = options ?? {};\n\n const formatter = new Intl.NumberFormat(locale, intlOptions);\n\n return formatter.format(value);\n}\n","/**\n * RTL(从右到左)语言支持\n * 用于判断语言是否需要 RTL 布局方向\n */\n\n/** RTL 语言列表 */\nconst RTL_LOCALES: ReadonlySet<string> = new Set([\n 'ar-SA',\n 'he-IL',\n 'fa-IR',\n]);\n\n/**\n * 判断指定 locale 是否为 RTL 语言\n *\n * @param locale - 语言标识(如 'ar-SA')\n * @returns 是否为 RTL 语言\n */\nexport function isRtl(locale: string): boolean {\n return RTL_LOCALES.has(locale);\n}\n\n/** 获取所有 RTL locale 列表(只读) */\nexport function getRtlLocales(): readonly string[] {\n return [...RTL_LOCALES];\n}\n","/**\n * @shopplus/membership-i18n 入口\n * 会员中台共享国际化 - 语言包 + 格式化函数 + RTL 支持\n */\n\n// 格式化函数导出\nexport { formatCurrency } from './format/currency';\nexport type { FormatCurrencyOptions } from './format/currency';\n\nexport { formatDate, formatRelativeTime } from './format/date';\nexport type { FormatDateOptions } from './format/date';\n\nexport { formatNumber } from './format/number';\nexport type { FormatNumberOptions } from './format/number';\n\n// RTL 支持\nexport { isRtl, getRtlLocales } from './rtl';\n\n// 类型定义\nimport type zhCN from './locales/zh-CN.json';\n\n/** 语言包类型(基于 zh-CN 推导) */\nexport type LocaleMessages = typeof zhCN;\n\n/** 支持的语言(12 种 = PRD §10.3 双 CN + 主流欧美亚 + 阿拉伯/希伯来 RTL + LATAM 葡 + 泰) */\nexport type SupportedLocale =\n | 'zh-CN'\n | 'zh-TW'\n | 'en-US'\n | 'ja-JP'\n | 'ko-KR'\n | 'fr-FR'\n | 'de-DE'\n | 'es-ES'\n | 'pt-BR'\n | 'ar-SA'\n | 'he-IL'\n | 'th-TH';\n\n/** 翻译函数参数 */\nexport interface TranslateParams {\n [key: string]: string | number;\n}\n\n// 语言包注册表\nconst localeMap = new Map<string, LocaleMessages>();\n\n/** 当前激活的语言 */\nlet currentLocale: string = 'zh-CN';\n\n/**\n * 注册语言包\n */\nexport function registerLocale(locale: string, messages: LocaleMessages): void {\n localeMap.set(locale, messages);\n}\n\n/**\n * 设置当前语言\n */\nexport function setLocale(locale: string): void {\n currentLocale = locale;\n}\n\n/**\n * 获取当前语言\n */\nexport function getLocale(): string {\n return currentLocale;\n}\n\n/**\n * 翻译函数\n * 支持插值:t('points.earn', { amount: 100 }) => \"获得 100 积分\"\n *\n * @param key - 翻译键(点分隔,如 'common.points')\n * @param params - 插值参数\n * @returns 翻译后的文本\n */\nexport function t(key: string, params?: TranslateParams): string {\n const messages = localeMap.get(currentLocale);\n if (!messages) return key;\n\n // 解析点分隔路径\n const parts = key.split('.');\n let result: unknown = messages;\n\n for (const part of parts) {\n if (result === null || result === undefined || typeof result !== 'object') {\n return key;\n }\n result = (result as Record<string, unknown>)[part];\n }\n\n if (typeof result !== 'string') return key;\n\n // 插值替换 {key} => value\n if (!params) return result;\n\n return result.replace(/\\{(\\w+)\\}/g, (_, paramKey: string) => {\n const value = params[paramKey];\n return value !== undefined ? String(value) : `{${paramKey}}`;\n });\n}\n\n/**\n * 初始化内置语言包\n * 延迟加载,避免打包体积过大\n */\nexport async function loadBuiltinLocale(locale: SupportedLocale): Promise<void> {\n let messages: LocaleMessages;\n\n switch (locale) {\n case 'zh-CN':\n messages = (await import('./locales/zh-CN.json')).default as LocaleMessages;\n break;\n case 'zh-TW':\n messages = (await import('./locales/zh-TW.json')).default as LocaleMessages;\n break;\n case 'en-US':\n messages = (await import('./locales/en-US.json')).default as LocaleMessages;\n break;\n case 'ja-JP':\n messages = (await import('./locales/ja-JP.json')).default as LocaleMessages;\n break;\n case 'ko-KR':\n messages = (await import('./locales/ko-KR.json')).default as LocaleMessages;\n break;\n case 'fr-FR':\n messages = (await import('./locales/fr-FR.json')).default as LocaleMessages;\n break;\n case 'de-DE':\n messages = (await import('./locales/de-DE.json')).default as LocaleMessages;\n break;\n case 'es-ES':\n messages = (await import('./locales/es-ES.json')).default as LocaleMessages;\n break;\n case 'pt-BR':\n messages = (await import('./locales/pt-BR.json')).default as LocaleMessages;\n break;\n case 'ar-SA':\n messages = (await import('./locales/ar-SA.json')).default as LocaleMessages;\n break;\n case 'he-IL':\n messages = (await import('./locales/he-IL.json')).default as LocaleMessages;\n break;\n case 'th-TH':\n messages = (await import('./locales/th-TH.json')).default as LocaleMessages;\n break;\n default:\n throw new Error(`Unsupported locale: ${locale}`);\n }\n\n registerLocale(locale, messages);\n setLocale(locale);\n}\n"],"mappings":"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"}
|