@shopplus/membership-i18n
v0.4.2
Published
会员中台共享国际化 - 12 种语言包 + Intl 格式化函数 + RTL 支持
Maintainers
Readme
@shopplus/membership-i18n
Shared internationalization package for ShopPlus Membership SDK. 12 locales, Intl-based formatting, RTL support.
Features
- 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
- 106 error code translations per locale
- UI component text translations
- Currency, number, and date formatting via
IntlAPIs - RTL detection (Arabic, Hebrew)
- Lazy-loaded locale chunks (only loaded locale is bundled)
- Zero runtime dependencies
Install
npm install @shopplus/membership-i18nQuick Start
import { createI18n } from '@shopplus/membership-i18n';
const i18n = await createI18n('zh-CN');
// Translate a key
i18n.t('common.points'); // "积分"
i18n.t('points.earn', { amount: 100 }); // "获得 100 积分"
// Error code translation
i18n.t('sdk.error.210922'); // "验证码发送过于频繁,请稍后再试"Formatting
import { formatCurrency, formatNumber, formatDate } from '@shopplus/membership-i18n';
// Currency (uses Intl.NumberFormat)
formatCurrency(99.5, 'USD', 'en-US'); // "$99.50"
formatCurrency(1280, 'JPY', 'ja-JP'); // "¥1,280"
// Number
formatNumber(12345.6, 'de-DE'); // "12.345,6"
// Date (uses Intl.DateTimeFormat)
formatDate(new Date(), 'zh-CN'); // "2026年7月1日"RTL Support
import { isRTL } from '@shopplus/membership-i18n';
isRTL('ar-SA'); // true
isRTL('he-IL'); // true
isRTL('en-US'); // falseAvailable Locales
| Locale | Language | Direction |
|---|---|---|
| en-US | English | LTR |
| zh-CN | Simplified Chinese | LTR |
| zh-TW | Traditional Chinese | LTR |
| ja-JP | Japanese | LTR |
| ko-KR | Korean | LTR |
| fr-FR | French | LTR |
| de-DE | German | LTR |
| es-ES | Spanish | LTR |
| pt-BR | Brazilian Portuguese | LTR |
| th-TH | Thai | LTR |
| ar-SA | Arabic | RTL |
| he-IL | Hebrew | RTL |
Translation Keys
| Namespace | Description |
|---|---|
| common.* | Shared UI text (confirm, cancel, loading...) |
| points.* | Points-related messages |
| level.* | Level/tier messages |
| coupon.* | Coupon status text |
| checkin.* | Check-in messages |
| errors.* | Generic error messages |
| ui.* | UI component text (member center, forms, etc.) |
| sdk.error.* | Error code translations (106 codes) |
Module Formats
| Format | File | Usage |
|---|---|---|
| ESM | dist/index.es.js | Bundlers (locale chunks lazy-loaded) |
| UMD | dist/index.umd.js | Script tag (all locales bundled) |
| Types | dist/index.d.ts | TypeScript support |
License
MIT
