ngxsmk-datepicker 2.3.1 → 2.4.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.
@@ -1,300 +1,300 @@
1
- # Locale Packs & i18n Contributor Guide
2
-
3
- **Last updated:** June 3, 2026 - **Current stable:** v2.3.1
4
-
5
- Guide for adding locale support and contributing translations to ngxsmk-datepicker.
6
-
7
- ## Overview
8
-
9
- ngxsmk-datepicker uses the browser's native `Intl` API for localization, which means it automatically supports many locales out of the box. However, you can enhance locale support by providing custom locale data or contributing locale-specific improvements.
10
-
11
- ## How Localization Works
12
-
13
- The component uses the `locale` input property to determine:
14
- - Month names
15
- - Weekday names
16
- - Week start day
17
- - Date formatting (locale-aware when using Intl; override with `[displayFormat]` for custom patterns)
18
- - Number formatting (locale-aware via `formatLocaleNumber` and translation registry)
19
-
20
- ```typescript
21
- <ngxsmk-datepicker [locale]="'en-US'"></ngxsmk-datepicker>
22
- <ngxsmk-datepicker [locale]="'de-DE'"></ngxsmk-datepicker>
23
- <ngxsmk-datepicker [locale]="'fr-FR'"></ngxsmk-datepicker>
24
- ```
25
-
26
- ## Supported Locales
27
-
28
- The component automatically supports all locales supported by the browser's `Intl` API, including:
29
-
30
- - **English**: `en-US`, `en-GB`, `en-CA`, etc.
31
- - **German**: `de-DE`, `de-AT`, `de-CH`
32
- - **French**: `fr-FR`, `fr-CA`, `fr-BE`
33
- - **Spanish**: `es-ES`, `es-MX`, `es-AR`
34
- - **Italian**: `it-IT`
35
- - **Portuguese**: `pt-BR`, `pt-PT`
36
- - **Japanese**: `ja-JP`
37
- - **Chinese**: `zh-CN`, `zh-TW`
38
- - **Korean**: `ko-KR`
39
- - **Arabic**: `ar-SA`, `ar-EG`
40
- - **Hebrew**: `he-IL`
41
- - **Russian**: `ru-RU`
42
- - And many more...
43
-
44
- ## Adding Custom Locale Data
45
-
46
- If you need custom locale behavior, you can use the `weekStart` input to override the automatic detection:
47
-
48
- ```typescript
49
- // Force Monday as first day of week for any locale
50
- <ngxsmk-datepicker
51
- [locale]="'en-US'"
52
- [weekStart]="1">
53
- </ngxsmk-datepicker>
54
- ```
55
-
56
- ## Contributing Locale Improvements
57
-
58
- ### 1. Testing Locale Support
59
-
60
- Create a test file to verify locale behavior:
61
-
62
- ```typescript
63
- // projects/ngxsmk-datepicker/src/lib/locales/locale-[code].spec.ts
64
- import { ComponentFixture, TestBed } from '@angular/core/testing';
65
- import { NgxsmkDatepickerComponent } from '../ngxsmk-datepicker';
66
-
67
- describe('Locale Support: [Locale Code]', () => {
68
- let component: NgxsmkDatepickerComponent;
69
- let fixture: ComponentFixture<NgxsmkDatepickerComponent>;
70
-
71
- beforeEach(async () => {
72
- await TestBed.configureTestingModule({
73
- imports: [NgxsmkDatepickerComponent],
74
- }).compileComponents();
75
-
76
- fixture = TestBed.createComponent(NgxsmkDatepickerComponent);
77
- component = fixture.componentInstance;
78
- component.locale = '[locale-code]';
79
- component.inline = true;
80
- fixture.detectChanges();
81
- });
82
-
83
- it('should display month names correctly', () => {
84
- // Test month names
85
- });
86
-
87
- it('should display weekday names correctly', () => {
88
- // Test weekday names
89
- });
90
-
91
- it('should use correct week start day', () => {
92
- // Test week start
93
- });
94
- });
95
- ```
96
-
97
- ### 2. Locale-Specific Configuration
98
-
99
- Create a locale configuration file:
100
-
101
- ```typescript
102
- // projects/ngxsmk-datepicker/src/lib/locales/[locale-code].config.ts
103
- export const LOCALE_CONFIG = {
104
- code: '[locale-code]',
105
- weekStart: 1, // Monday
106
- dateFormat: 'DD/MM/YYYY',
107
- timeFormat: 'HH:mm',
108
- monthNames: [...],
109
- weekdayNames: [...]
110
- };
111
- ```
112
-
113
- ### 3. RTL Locale Support
114
-
115
- For RTL languages (Arabic, Hebrew, etc.), the component automatically detects RTL:
116
-
117
- ```typescript
118
- // Automatically enabled for RTL locales
119
- <ngxsmk-datepicker [locale]="'ar-SA'"></ngxsmk-datepicker>
120
- <ngxsmk-datepicker [locale]="'he-IL'"></ngxsmk-datepicker>
121
-
122
- // Or explicitly set
123
- <ngxsmk-datepicker [locale]="'ar-SA'" [rtl]="true"></ngxsmk-datepicker>
124
- ```
125
-
126
- ## Locale Testing Checklist
127
-
128
- When adding or testing a locale, verify:
129
-
130
- - [ ] Month names display correctly
131
- - [ ] Weekday names display correctly
132
- - [ ] Week start day is correct for the locale
133
- - [ ] Date formatting matches locale conventions
134
- - [ ] RTL layout works (if applicable)
135
- - [ ] Time formatting (12h/24h) matches locale
136
- - [ ] Number formatting is correct
137
- - [ ] Calendar navigation works correctly
138
- - [ ] Keyboard navigation works in RTL mode (if applicable)
139
-
140
- ## Example: Adding French Locale Support
141
-
142
- ```typescript
143
- // Test file
144
- describe('French Locale (fr-FR)', () => {
145
- it('should display French month names', () => {
146
- component.locale = 'fr-FR';
147
- fixture.detectChanges();
148
-
149
- const monthSelect = fixture.debugElement.query(By.css('.month-select'));
150
- expect(monthSelect).toBeTruthy();
151
- // Verify French month names appear
152
- });
153
-
154
- it('should start week on Monday', () => {
155
- component.locale = 'fr-FR';
156
- component.weekStart = null; // Use locale default
157
- fixture.detectChanges();
158
-
159
- // Verify week starts on Monday (day 1)
160
- expect(component.firstDayOfWeek).toBe(1);
161
- });
162
- });
163
- ```
164
-
165
- ## Locale-Specific Features
166
-
167
- ### Week Start Day
168
-
169
- Different locales have different week start days:
170
- - **Monday**: Most European countries (de, fr, es, it, etc.)
171
- - **Sunday**: US, Canada, some Asian countries
172
- - **Saturday**: Some Middle Eastern countries
173
-
174
- The component auto-detects this, but you can override:
175
-
176
- ```typescript
177
- provideDatepickerConfig({
178
- weekStart: 1 // Force Monday globally
179
- })
180
- ```
181
-
182
- ### Date Format
183
-
184
- Date formats vary by locale:
185
- - **US**: `MM/DD/YYYY` (e.g., 12/25/2025)
186
- - **Europe**: `DD/MM/YYYY` (e.g., 25/12/2025)
187
- - **ISO**: `YYYY-MM-DD` (e.g., 2025-12-25)
188
- - **Asia**: `YYYY年MM月DD日` (e.g., 2025年12月25日)
189
-
190
- The component uses `Intl.DateTimeFormat` which handles this automatically.
191
-
192
- ## Contributing Process
193
-
194
- 1. **Fork the repository**
195
- 2. **Create a test file** for your locale
196
- 3. **Test the locale** thoroughly
197
- 4. **Document any issues** or special considerations
198
- 5. **Submit a pull request** with:
199
- - Test file
200
- - Documentation updates
201
- - Any locale-specific fixes
202
-
203
- ## Locale Test Template
204
-
205
- ```typescript
206
- import { ComponentFixture, TestBed } from '@angular/core/testing';
207
- import { By } from '@angular/platform-browser';
208
- import { NgxsmkDatepickerComponent } from '../ngxsmk-datepicker';
209
-
210
- describe('Locale: [Your Locale]', () => {
211
- let component: NgxsmkDatepickerComponent;
212
- let fixture: ComponentFixture<NgxsmkDatepickerComponent>;
213
-
214
- beforeEach(async () => {
215
- await TestBed.configureTestingModule({
216
- imports: [NgxsmkDatepickerComponent],
217
- }).compileComponents();
218
-
219
- fixture = TestBed.createComponent(NgxsmkDatepickerComponent);
220
- component = fixture.componentInstance;
221
- component.locale = '[locale-code]';
222
- component.inline = true;
223
- fixture.detectChanges();
224
- });
225
-
226
- describe('Month Names', () => {
227
- it('should display correct month names', () => {
228
- // Your test
229
- });
230
- });
231
-
232
- describe('Weekday Names', () => {
233
- it('should display correct weekday names', () => {
234
- // Your test
235
- });
236
- });
237
-
238
- describe('Week Start', () => {
239
- it('should use correct week start day', () => {
240
- // Your test
241
- });
242
- });
243
-
244
- describe('Date Formatting', () => {
245
- it('should format dates correctly', () => {
246
- // Your test
247
- });
248
- });
249
-
250
- @if (isRtlLocale) {
251
- describe('RTL Support', () => {
252
- it('should render in RTL mode', () => {
253
- // Your test
254
- });
255
- });
256
- }
257
- });
258
- ```
259
-
260
- ## Common Locale Issues
261
-
262
- ### Issue: Week Start Day Incorrect
263
-
264
- **Solution**: Use `weekStart` input to override:
265
-
266
- ```typescript
267
- <ngxsmk-datepicker
268
- [locale]="'en-US'"
269
- [weekStart]="1">
270
- </ngxsmk-datepicker>
271
- ```
272
-
273
- ### Issue: Date Format Not Matching Locale
274
-
275
- **Solution**: The component uses `Intl.DateTimeFormat`. If you need custom formatting, use the `hooks.formatDisplayValue` hook.
276
-
277
- ### Issue: RTL Not Detected
278
-
279
- **Solution**: Explicitly set `[rtl]="true"` or ensure `document.dir` is set correctly.
280
-
281
- ## Resources
282
-
283
- - [MDN: Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat)
284
- - [BCP 47 Language Tags](https://en.wikipedia.org/wiki/IETF_language_tag)
285
- - [Locale Data](https://github.com/unicode-org/cldr-json)
286
-
287
- ## Questions?
288
-
289
- If you encounter issues with a specific locale or want to contribute improvements:
290
-
291
- 1. Open an issue with the locale code and description
292
- 2. Check existing issues for similar problems
293
- 3. Submit a PR with your locale improvements
294
-
295
- ---
296
-
297
- **Thank you for contributing to ngxsmk-datepicker's internationalization!**
298
-
299
-
300
-
1
+ # Locale Packs & i18n Contributor Guide
2
+
3
+ **Last updated:** July 2, 2026 - **Current stable:** v2.4.0
4
+
5
+ Guide for adding locale support and contributing translations to ngxsmk-datepicker.
6
+
7
+ ## Overview
8
+
9
+ ngxsmk-datepicker uses the browser's native `Intl` API for localization, which means it automatically supports many locales out of the box. However, you can enhance locale support by providing custom locale data or contributing locale-specific improvements.
10
+
11
+ ## How Localization Works
12
+
13
+ The component uses the `locale` input property to determine:
14
+ - Month names
15
+ - Weekday names
16
+ - Week start day
17
+ - Date formatting (locale-aware when using Intl; override with `[displayFormat]` for custom patterns)
18
+ - Number formatting (locale-aware via `formatLocaleNumber` and translation registry)
19
+
20
+ ```typescript
21
+ <ngxsmk-datepicker [locale]="'en-US'"></ngxsmk-datepicker>
22
+ <ngxsmk-datepicker [locale]="'de-DE'"></ngxsmk-datepicker>
23
+ <ngxsmk-datepicker [locale]="'fr-FR'"></ngxsmk-datepicker>
24
+ ```
25
+
26
+ ## Supported Locales
27
+
28
+ The component automatically supports all locales supported by the browser's `Intl` API, including:
29
+
30
+ - **English**: `en-US`, `en-GB`, `en-CA`, etc.
31
+ - **German**: `de-DE`, `de-AT`, `de-CH`
32
+ - **French**: `fr-FR`, `fr-CA`, `fr-BE`
33
+ - **Spanish**: `es-ES`, `es-MX`, `es-AR`
34
+ - **Italian**: `it-IT`
35
+ - **Portuguese**: `pt-BR`, `pt-PT`
36
+ - **Japanese**: `ja-JP`
37
+ - **Chinese**: `zh-CN`, `zh-TW`
38
+ - **Korean**: `ko-KR`
39
+ - **Arabic**: `ar-SA`, `ar-EG`
40
+ - **Hebrew**: `he-IL`
41
+ - **Russian**: `ru-RU`
42
+ - And many more...
43
+
44
+ ## Adding Custom Locale Data
45
+
46
+ If you need custom locale behavior, you can use the `weekStart` input to override the automatic detection:
47
+
48
+ ```typescript
49
+ // Force Monday as first day of week for any locale
50
+ <ngxsmk-datepicker
51
+ [locale]="'en-US'"
52
+ [weekStart]="1">
53
+ </ngxsmk-datepicker>
54
+ ```
55
+
56
+ ## Contributing Locale Improvements
57
+
58
+ ### 1. Testing Locale Support
59
+
60
+ Create a test file to verify locale behavior:
61
+
62
+ ```typescript
63
+ // projects/ngxsmk-datepicker/src/lib/locales/locale-[code].spec.ts
64
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
65
+ import { NgxsmkDatepickerComponent } from '../ngxsmk-datepicker';
66
+
67
+ describe('Locale Support: [Locale Code]', () => {
68
+ let component: NgxsmkDatepickerComponent;
69
+ let fixture: ComponentFixture<NgxsmkDatepickerComponent>;
70
+
71
+ beforeEach(async () => {
72
+ await TestBed.configureTestingModule({
73
+ imports: [NgxsmkDatepickerComponent],
74
+ }).compileComponents();
75
+
76
+ fixture = TestBed.createComponent(NgxsmkDatepickerComponent);
77
+ component = fixture.componentInstance;
78
+ component.locale = '[locale-code]';
79
+ component.inline = true;
80
+ fixture.detectChanges();
81
+ });
82
+
83
+ it('should display month names correctly', () => {
84
+ // Test month names
85
+ });
86
+
87
+ it('should display weekday names correctly', () => {
88
+ // Test weekday names
89
+ });
90
+
91
+ it('should use correct week start day', () => {
92
+ // Test week start
93
+ });
94
+ });
95
+ ```
96
+
97
+ ### 2. Locale-Specific Configuration
98
+
99
+ Create a locale configuration file:
100
+
101
+ ```typescript
102
+ // projects/ngxsmk-datepicker/src/lib/locales/[locale-code].config.ts
103
+ export const LOCALE_CONFIG = {
104
+ code: '[locale-code]',
105
+ weekStart: 1, // Monday
106
+ dateFormat: 'DD/MM/YYYY',
107
+ timeFormat: 'HH:mm',
108
+ monthNames: [...],
109
+ weekdayNames: [...]
110
+ };
111
+ ```
112
+
113
+ ### 3. RTL Locale Support
114
+
115
+ For RTL languages (Arabic, Hebrew, etc.), the component automatically detects RTL:
116
+
117
+ ```typescript
118
+ // Automatically enabled for RTL locales
119
+ <ngxsmk-datepicker [locale]="'ar-SA'"></ngxsmk-datepicker>
120
+ <ngxsmk-datepicker [locale]="'he-IL'"></ngxsmk-datepicker>
121
+
122
+ // Or explicitly set
123
+ <ngxsmk-datepicker [locale]="'ar-SA'" [rtl]="true"></ngxsmk-datepicker>
124
+ ```
125
+
126
+ ## Locale Testing Checklist
127
+
128
+ When adding or testing a locale, verify:
129
+
130
+ - [ ] Month names display correctly
131
+ - [ ] Weekday names display correctly
132
+ - [ ] Week start day is correct for the locale
133
+ - [ ] Date formatting matches locale conventions
134
+ - [ ] RTL layout works (if applicable)
135
+ - [ ] Time formatting (12h/24h) matches locale
136
+ - [ ] Number formatting is correct
137
+ - [ ] Calendar navigation works correctly
138
+ - [ ] Keyboard navigation works in RTL mode (if applicable)
139
+
140
+ ## Example: Adding French Locale Support
141
+
142
+ ```typescript
143
+ // Test file
144
+ describe('French Locale (fr-FR)', () => {
145
+ it('should display French month names', () => {
146
+ component.locale = 'fr-FR';
147
+ fixture.detectChanges();
148
+
149
+ const monthSelect = fixture.debugElement.query(By.css('.month-select'));
150
+ expect(monthSelect).toBeTruthy();
151
+ // Verify French month names appear
152
+ });
153
+
154
+ it('should start week on Monday', () => {
155
+ component.locale = 'fr-FR';
156
+ component.weekStart = null; // Use locale default
157
+ fixture.detectChanges();
158
+
159
+ // Verify week starts on Monday (day 1)
160
+ expect(component.firstDayOfWeek).toBe(1);
161
+ });
162
+ });
163
+ ```
164
+
165
+ ## Locale-Specific Features
166
+
167
+ ### Week Start Day
168
+
169
+ Different locales have different week start days:
170
+ - **Monday**: Most European countries (de, fr, es, it, etc.)
171
+ - **Sunday**: US, Canada, some Asian countries
172
+ - **Saturday**: Some Middle Eastern countries
173
+
174
+ The component auto-detects this, but you can override:
175
+
176
+ ```typescript
177
+ provideDatepickerConfig({
178
+ weekStart: 1 // Force Monday globally
179
+ })
180
+ ```
181
+
182
+ ### Date Format
183
+
184
+ Date formats vary by locale:
185
+ - **US**: `MM/DD/YYYY` (e.g., 12/25/2025)
186
+ - **Europe**: `DD/MM/YYYY` (e.g., 25/12/2025)
187
+ - **ISO**: `YYYY-MM-DD` (e.g., 2025-12-25)
188
+ - **Asia**: `YYYY年MM月DD日` (e.g., 2025年12月25日)
189
+
190
+ The component uses `Intl.DateTimeFormat` which handles this automatically.
191
+
192
+ ## Contributing Process
193
+
194
+ 1. **Fork the repository**
195
+ 2. **Create a test file** for your locale
196
+ 3. **Test the locale** thoroughly
197
+ 4. **Document any issues** or special considerations
198
+ 5. **Submit a pull request** with:
199
+ - Test file
200
+ - Documentation updates
201
+ - Any locale-specific fixes
202
+
203
+ ## Locale Test Template
204
+
205
+ ```typescript
206
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
207
+ import { By } from '@angular/platform-browser';
208
+ import { NgxsmkDatepickerComponent } from '../ngxsmk-datepicker';
209
+
210
+ describe('Locale: [Your Locale]', () => {
211
+ let component: NgxsmkDatepickerComponent;
212
+ let fixture: ComponentFixture<NgxsmkDatepickerComponent>;
213
+
214
+ beforeEach(async () => {
215
+ await TestBed.configureTestingModule({
216
+ imports: [NgxsmkDatepickerComponent],
217
+ }).compileComponents();
218
+
219
+ fixture = TestBed.createComponent(NgxsmkDatepickerComponent);
220
+ component = fixture.componentInstance;
221
+ component.locale = '[locale-code]';
222
+ component.inline = true;
223
+ fixture.detectChanges();
224
+ });
225
+
226
+ describe('Month Names', () => {
227
+ it('should display correct month names', () => {
228
+ // Your test
229
+ });
230
+ });
231
+
232
+ describe('Weekday Names', () => {
233
+ it('should display correct weekday names', () => {
234
+ // Your test
235
+ });
236
+ });
237
+
238
+ describe('Week Start', () => {
239
+ it('should use correct week start day', () => {
240
+ // Your test
241
+ });
242
+ });
243
+
244
+ describe('Date Formatting', () => {
245
+ it('should format dates correctly', () => {
246
+ // Your test
247
+ });
248
+ });
249
+
250
+ @if (isRtlLocale) {
251
+ describe('RTL Support', () => {
252
+ it('should render in RTL mode', () => {
253
+ // Your test
254
+ });
255
+ });
256
+ }
257
+ });
258
+ ```
259
+
260
+ ## Common Locale Issues
261
+
262
+ ### Issue: Week Start Day Incorrect
263
+
264
+ **Solution**: Use `weekStart` input to override:
265
+
266
+ ```typescript
267
+ <ngxsmk-datepicker
268
+ [locale]="'en-US'"
269
+ [weekStart]="1">
270
+ </ngxsmk-datepicker>
271
+ ```
272
+
273
+ ### Issue: Date Format Not Matching Locale
274
+
275
+ **Solution**: The component uses `Intl.DateTimeFormat`. If you need custom formatting, use the `hooks.formatDisplayValue` hook.
276
+
277
+ ### Issue: RTL Not Detected
278
+
279
+ **Solution**: Explicitly set `[rtl]="true"` or ensure `document.dir` is set correctly.
280
+
281
+ ## Resources
282
+
283
+ - [MDN: Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat)
284
+ - [BCP 47 Language Tags](https://en.wikipedia.org/wiki/IETF_language_tag)
285
+ - [Locale Data](https://github.com/unicode-org/cldr-json)
286
+
287
+ ## Questions?
288
+
289
+ If you encounter issues with a specific locale or want to contribute improvements:
290
+
291
+ 1. Open an issue with the locale code and description
292
+ 2. Check existing issues for similar problems
293
+ 3. Submit a PR with your locale improvements
294
+
295
+ ---
296
+
297
+ **Thank you for contributing to ngxsmk-datepicker's internationalization!**
298
+
299
+
300
+