@stacksjs/i18n 0.70.88 → 0.70.90

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.
@@ -0,0 +1,213 @@
1
+ /**
2
+ * Common locales with metadata
3
+ * @defaultValue
4
+ * ```ts
5
+ * {
6
+ * en: { code: 'en', name: 'English', nativeName: 'English', direction: 'ltr' },
7
+ * 'en-US': {
8
+ * code: 'en-US',
9
+ * name: 'English (US)',
10
+ * nativeName: 'English (US)',
11
+ * direction: 'ltr',
12
+ * region: 'US'
13
+ * },
14
+ * 'en-GB': {
15
+ * code: 'en-GB',
16
+ * name: 'English (UK)',
17
+ * nativeName: 'English (UK)',
18
+ * direction: 'ltr',
19
+ * region: 'GB'
20
+ * },
21
+ * es: { code: 'es', name: 'Spanish', nativeName: 'Espa\u00f1ol', direction: 'ltr' },
22
+ * fr: { code: 'fr', name: 'French', nativeName: 'Fran\u00e7ais', direction: 'ltr' },
23
+ * de: { code: 'de', name: 'German', nativeName: 'Deutsch', direction: 'ltr' },
24
+ * it: { code: 'it', name: 'Italian', nativeName: 'Italiano', direction: 'ltr' },
25
+ * pt: {
26
+ * code: 'pt',
27
+ * name: 'Portuguese',
28
+ * nativeName: 'Portugu\u00eas',
29
+ * direction: 'ltr'
30
+ * },
31
+ * 'pt-BR': {
32
+ * code: 'pt-BR',
33
+ * name: 'Portuguese (Brazil)',
34
+ * nativeName: 'Portugu\u00eas (Brasil)',
35
+ * direction: 'ltr',
36
+ * region: 'BR'
37
+ * },
38
+ * zh: { code: 'zh', name: 'Chinese', nativeName: '\u4e2d\u6587', direction: 'ltr' },
39
+ * 'zh-CN': {
40
+ * code: 'zh-CN',
41
+ * name: 'Chinese (Simplified)',
42
+ * nativeName: '\u7b80\u4f53\u4e2d\u6587',
43
+ * direction: 'ltr',
44
+ * region: 'CN'
45
+ * },
46
+ * 'zh-TW': {
47
+ * code: 'zh-TW',
48
+ * name: 'Chinese (Traditional)',
49
+ * nativeName: '\u7e41\u9ad4\u4e2d\u6587',
50
+ * direction: 'ltr',
51
+ * region: 'TW'
52
+ * },
53
+ * ja: {
54
+ * code: 'ja',
55
+ * name: 'Japanese',
56
+ * nativeName: '\u65e5\u672c\u8a9e',
57
+ * direction: 'ltr'
58
+ * },
59
+ * ko: {
60
+ * code: 'ko',
61
+ * name: 'Korean',
62
+ * nativeName: '\ud55c\uad6d\uc5b4',
63
+ * direction: 'ltr'
64
+ * },
65
+ * ar: {
66
+ * code: 'ar',
67
+ * name: 'Arabic',
68
+ * nativeName: '\u0627\u0644\u0639\u0631\u0628\u064a\u0629',
69
+ * direction: 'rtl'
70
+ * },
71
+ * he: {
72
+ * code: 'he',
73
+ * name: 'Hebrew',
74
+ * nativeName: '\u05e2\u05d1\u05e8\u05d9\u05ea',
75
+ * direction: 'rtl'
76
+ * },
77
+ * ru: {
78
+ * code: 'ru',
79
+ * name: 'Russian',
80
+ * nativeName: '\u0420\u0443\u0441\u0441\u043a\u0438\u0439',
81
+ * direction: 'ltr'
82
+ * },
83
+ * nl: { code: 'nl', name: 'Dutch', nativeName: 'Nederlands', direction: 'ltr' },
84
+ * pl: { code: 'pl', name: 'Polish', nativeName: 'Polski', direction: 'ltr' },
85
+ * tr: {
86
+ * code: 'tr',
87
+ * name: 'Turkish',
88
+ * nativeName: 'T\u00fcrk\u00e7e',
89
+ * direction: 'ltr'
90
+ * },
91
+ * vi: {
92
+ * code: 'vi',
93
+ * name: 'Vietnamese',
94
+ * nativeName: 'Ti\u1ebfng Vi\u1ec7t',
95
+ * direction: 'ltr'
96
+ * },
97
+ * th: { code: 'th', name: 'Thai', nativeName: '\u0e44\u0e17\u0e22', direction: 'ltr' },
98
+ * hi: {
99
+ * code: 'hi',
100
+ * name: 'Hindi',
101
+ * nativeName: '\u0939\u093f\u0928\u094d\u0926\u0940',
102
+ * direction: 'ltr'
103
+ * }
104
+ * }
105
+ * ```
106
+ */
107
+ export declare const LOCALE_INFO: Record<string, LocaleInfo>;
108
+ /**
109
+ * Plural forms for a translation
110
+ */
111
+ export declare interface PluralForms {
112
+ zero?: string
113
+ one: string
114
+ two?: string
115
+ few?: string
116
+ many?: string
117
+ other: string
118
+ }
119
+ /**
120
+ * i18n configuration options
121
+ */
122
+ export declare interface I18nConfig {
123
+ locale: string
124
+ fallbackLocale: string
125
+ availableLocales?: string[]
126
+ messages?: Translations
127
+ missingHandler?: (locale: string, key: string) => string | undefined
128
+ warnMissing?: boolean
129
+ escapeValues?: boolean
130
+ keySeparator?: string
131
+ pluralSeparator?: string
132
+ dateTimeFormats?: DateTimeFormats
133
+ numberFormats?: NumberFormats
134
+ }
135
+ /**
136
+ * i18n instance interface
137
+ */
138
+ export declare interface I18nInstance {
139
+ locale: string
140
+ fallbackLocale: string
141
+ availableLocales: string[]
142
+ t: TranslateFunction
143
+ tc: TranslatePluralFunction
144
+ te: (key: string, locale?: string) => boolean
145
+ tm: (key: string, locale?: string) => TranslationMessages | string | undefined
146
+ setLocale: (locale: string) => void
147
+ addTranslations: (locale: string, messages: TranslationMessages) => void
148
+ d: (value: Date | number, format?: string) => string
149
+ n: (value: number, format?: string) => string
150
+ }
151
+ /**
152
+ * Locale metadata
153
+ */
154
+ export declare interface LocaleInfo {
155
+ code: string
156
+ name: string
157
+ nativeName: string
158
+ direction: 'ltr' | 'rtl'
159
+ region?: string
160
+ script?: string
161
+ }
162
+ /**
163
+ * i18n Type Definitions
164
+ */
165
+ /**
166
+ * Translation messages - can be nested objects or strings
167
+ */
168
+ export type TranslationMessages = {
169
+ [key: string]: string | TranslationMessages
170
+ }
171
+ /**
172
+ * All translations keyed by locale
173
+ */
174
+ export type Translations = {
175
+ [locale: string]: TranslationMessages
176
+ }
177
+ /**
178
+ * Interpolation values for translations
179
+ */
180
+ export type InterpolationValues = Record<string, string | number | boolean | null | undefined>;
181
+ /**
182
+ * Date/time format configurations per locale
183
+ */
184
+ export type DateTimeFormats = {
185
+ [locale: string]: {
186
+ [formatName: string]: Intl.DateTimeFormatOptions
187
+ }
188
+ }
189
+ /**
190
+ * Number format configurations per locale
191
+ */
192
+ export type NumberFormats = {
193
+ [locale: string]: {
194
+ [formatName: string]: Intl.NumberFormatOptions
195
+ }
196
+ }
197
+ /**
198
+ * Translation function
199
+ */
200
+ export type TranslateFunction = (
201
+ key: string,
202
+ values?: InterpolationValues,
203
+ locale?: string,
204
+ ) => string;
205
+ /**
206
+ * Plural translation function
207
+ */
208
+ export type TranslatePluralFunction = (
209
+ key: string,
210
+ count: number,
211
+ values?: InterpolationValues,
212
+ locale?: string,
213
+ ) => string;
package/dist/types.js ADDED
@@ -0,0 +1,25 @@
1
+ export const LOCALE_INFO = {
2
+ en: { code: "en", name: "English", nativeName: "English", direction: "ltr" },
3
+ "en-US": { code: "en-US", name: "English (US)", nativeName: "English (US)", direction: "ltr", region: "US" },
4
+ "en-GB": { code: "en-GB", name: "English (UK)", nativeName: "English (UK)", direction: "ltr", region: "GB" },
5
+ es: { code: "es", name: "Spanish", nativeName: "Espa\xF1ol", direction: "ltr" },
6
+ fr: { code: "fr", name: "French", nativeName: "Fran\xE7ais", direction: "ltr" },
7
+ de: { code: "de", name: "German", nativeName: "Deutsch", direction: "ltr" },
8
+ it: { code: "it", name: "Italian", nativeName: "Italiano", direction: "ltr" },
9
+ pt: { code: "pt", name: "Portuguese", nativeName: "Portugu\xEAs", direction: "ltr" },
10
+ "pt-BR": { code: "pt-BR", name: "Portuguese (Brazil)", nativeName: "Portugu\xEAs (Brasil)", direction: "ltr", region: "BR" },
11
+ zh: { code: "zh", name: "Chinese", nativeName: "\u4E2D\u6587", direction: "ltr" },
12
+ "zh-CN": { code: "zh-CN", name: "Chinese (Simplified)", nativeName: "\u7B80\u4F53\u4E2D\u6587", direction: "ltr", region: "CN" },
13
+ "zh-TW": { code: "zh-TW", name: "Chinese (Traditional)", nativeName: "\u7E41\u9AD4\u4E2D\u6587", direction: "ltr", region: "TW" },
14
+ ja: { code: "ja", name: "Japanese", nativeName: "\u65E5\u672C\u8A9E", direction: "ltr" },
15
+ ko: { code: "ko", name: "Korean", nativeName: "\uD55C\uAD6D\uC5B4", direction: "ltr" },
16
+ ar: { code: "ar", name: "Arabic", nativeName: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629", direction: "rtl" },
17
+ he: { code: "he", name: "Hebrew", nativeName: "\u05E2\u05D1\u05E8\u05D9\u05EA", direction: "rtl" },
18
+ ru: { code: "ru", name: "Russian", nativeName: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439", direction: "ltr" },
19
+ nl: { code: "nl", name: "Dutch", nativeName: "Nederlands", direction: "ltr" },
20
+ pl: { code: "pl", name: "Polish", nativeName: "Polski", direction: "ltr" },
21
+ tr: { code: "tr", name: "Turkish", nativeName: "T\xFCrk\xE7e", direction: "ltr" },
22
+ vi: { code: "vi", name: "Vietnamese", nativeName: "Ti\u1EBFng Vi\u1EC7t", direction: "ltr" },
23
+ th: { code: "th", name: "Thai", nativeName: "\u0E44\u0E17\u0E22", direction: "ltr" },
24
+ hi: { code: "hi", name: "Hindi", nativeName: "\u0939\u093F\u0928\u094D\u0926\u0940", direction: "ltr" }
25
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stacksjs/i18n",
3
- "version": "0.70.88",
3
+ "version": "0.70.90",
4
4
  "description": "Internationalization system for Stacks.js applications",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -40,7 +40,7 @@
40
40
  "@stacksjs/ts-i18n": "^0.1.9"
41
41
  },
42
42
  "devDependencies": {
43
- "@stacksjs/development": "0.70.88"
43
+ "@stacksjs/development": "0.70.90"
44
44
  },
45
45
  "publishConfig": {
46
46
  "exports": {