Skip to content

Commit d210ca6

Browse files
alihasan00githubhasanalivalorkinlexasq
authored
[Feature]: FR-CA integration (#6598)
* integrate fr-ca * fr-cal locale added * fr-ca locale added for datepicker and demo date-picker * feat(fr-ca): added tests * feat(fr-ca): added tests --------- Co-authored-by: githubhasanali <[email protected]> Co-authored-by: Dmitriy Shekhovtsov <[email protected]> Co-authored-by: Alexey Umanskiy <[email protected]>
1 parent 7c18759 commit d210ca6

File tree

8 files changed

+335
-11
lines changed

8 files changed

+335
-11
lines changed

libs/doc-pages/datepicker/src/lib/datepicker.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
arLocale, bgLocale, caLocale, csLocale, daLocale, deLocale, enGbLocale, esDoLocale, esLocale, esUsLocale, etLocale, frLocale, heLocale,
1111
hiLocale, hrLocale, fiLocale, glLocale, huLocale, idLocale, itLocale, jaLocale, kaLocale, kkLocale, koLocale, ltLocale, lvLocale, mnLocale, nbLocale,
1212
nlBeLocale, nlLocale, plLocale, ptBrLocale, ruLocale, roLocale, skLocale, slLocale, sqLocale, svLocale, thLocale, thBeLocale, trLocale, viLocale,
13-
zhCnLocale, ukLocale
13+
zhCnLocale, ukLocale, frCaLocale
1414
} from 'ngx-bootstrap/locale';
1515

1616
import { TabsModule } from 'ngx-bootstrap/tabs';
@@ -26,7 +26,7 @@ const locales = [
2626
arLocale, bgLocale, caLocale, csLocale, daLocale, deLocale, enGbLocale, esDoLocale, esLocale, esUsLocale, etLocale, frLocale,
2727
heLocale, hiLocale, hrLocale, fiLocale, glLocale, huLocale, idLocale, itLocale, jaLocale, kaLocale, kkLocale, koLocale, ltLocale, lvLocale, mnLocale,
2828
nbLocale, nlBeLocale, nlLocale, plLocale, ptBrLocale, ruLocale, roLocale, skLocale, slLocale, sqLocale, svLocale, thLocale, thBeLocale,
29-
trLocale, ukLocale, viLocale, zhCnLocale
29+
trLocale, ukLocale, viLocale, zhCnLocale, frCaLocale
3030
];
3131

3232
locales.forEach((locale: LocaleData) => {

libs/doc-pages/datepicker/src/lib/demo-datepicker.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
arLocale, bgLocale, caLocale, csLocale, daLocale, deLocale, enGbLocale, esDoLocale, esLocale, esPrLocale, esUsLocale, etLocale, frLocale, heLocale,
1111
hiLocale, hrLocale, fiLocale, glLocale, huLocale, idLocale, itLocale, jaLocale, kaLocale, kkLocale, koLocale, ltLocale, lvLocale, mnLocale, nbLocale,
1212
nlBeLocale, nlLocale, plLocale, ptBrLocale, ruLocale, roLocale, skLocale, slLocale, sqLocale, svLocale, thLocale, thBeLocale, trLocale, viLocale,
13-
zhCnLocale, ukLocale
13+
zhCnLocale, ukLocale, frCaLocale
1414
} from 'ngx-bootstrap/locale';
1515

1616
import { TabsModule } from 'ngx-bootstrap/tabs';
@@ -24,7 +24,7 @@ const locales = [
2424
arLocale, bgLocale, caLocale, csLocale, daLocale, deLocale, enGbLocale, esDoLocale, esLocale, esPrLocale, esUsLocale, etLocale, frLocale,
2525
heLocale, hiLocale, hrLocale, fiLocale, glLocale, huLocale, idLocale, itLocale, jaLocale, kaLocale, kkLocale, koLocale, ltLocale, lvLocale, mnLocale,
2626
nbLocale, nlBeLocale, nlLocale, plLocale, ptBrLocale, ruLocale, roLocale, skLocale, slLocale, sqLocale, svLocale, thLocale, thBeLocale,
27-
trLocale, ukLocale, viLocale, zhCnLocale
27+
trLocale, ukLocale, viLocale, zhCnLocale, frCaLocale
2828
];
2929

3030
locales.forEach((locale: LocaleData) => {

src/chronos/i18n/fr-ca.ts

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { LocaleData } from '../locale/locale.class';
2+
3+
//! moment.js locale configuration
4+
//! locale : French Canadian [fr-ca]
5+
//! author : Ali Hasan : https://github.com/alihasan00
6+
7+
export const frCaLocale: LocaleData = {
8+
abbr: 'fr-ca',
9+
months: 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
10+
monthsShort: 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
11+
monthsParseExact: true,
12+
weekdays: 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
13+
weekdaysShort: 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
14+
weekdaysMin: 'di_lu_ma_me_je_ve_sa'.split('_'),
15+
weekdaysParseExact: true,
16+
longDateFormat: {
17+
LT: 'HH:mm',
18+
LTS: 'HH:mm:ss',
19+
L: 'YYYY-MM-DD',
20+
LL: 'D MMMM YYYY',
21+
LLL: 'D MMMM YYYY HH:mm',
22+
LLLL: 'dddd D MMMM YYYY HH:mm'
23+
},
24+
calendar: {
25+
sameDay: '[Aujourd’hui à] LT',
26+
nextDay: '[Demain à] LT',
27+
nextWeek: 'dddd [à] LT',
28+
lastDay: '[Hier à] LT',
29+
lastWeek: 'dddd [dernier à] LT',
30+
sameElse: 'L'
31+
},
32+
relativeTime: {
33+
future: 'dans %s',
34+
past: 'il y a %s',
35+
s: 'quelques secondes',
36+
ss: '%d secondes',
37+
m: 'une minute',
38+
mm: '%d minutes',
39+
h: 'une heure',
40+
hh: '%d heures',
41+
d: 'un jour',
42+
dd: '%d jours',
43+
M: 'un mois',
44+
MM: '%d mois',
45+
y: 'un an',
46+
yy: '%d ans'
47+
},
48+
dayOfMonthOrdinalParse: /\d{1,2}(er|e|)/,
49+
ordinal(_num: number, period: string): string {
50+
const num = Number(_num);
51+
switch (period) {
52+
case 'D':
53+
return num + (num === 1 ? 'er' : '');
54+
55+
// Words with masculine grammatical gender: mois, trimestre, jour
56+
default:
57+
case 'M':
58+
case 'Q':
59+
case 'DDD':
60+
case 'd':
61+
return num + (num === 1 ? 'er' : 'e');
62+
63+
// Words with feminine grammatical gender: semaine
64+
case 'w':
65+
case 'W':
66+
return num + (num === 1 ? 're' : 'e');
67+
}
68+
},
69+
week: {
70+
dow: 1, // Monday is the first day of the week.
71+
doy: 4 // The week that contains Jan 4th is the first week of the year.
72+
}
73+
};

src/chronos/public_api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export { esUsLocale } from './i18n/es-us';
4848
export { etLocale } from './i18n/et';
4949
export { fiLocale } from './i18n/fi';
5050
export { frLocale } from './i18n/fr';
51+
export {frCaLocale} from './i18n/fr-ca';
5152
export { glLocale } from './i18n/gl';
5253
export { heLocale } from './i18n/he';
5354
export { hiLocale } from './i18n/hi';
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
2+
import { assertEq, assertDeepEq } from '../test-helpers';
3+
import { moment } from '../chain';
4+
import { frCaLocale } from '../../i18n/fr-ca';
5+
6+
describe('locale: fr-ca', () => {
7+
beforeAll(() => {
8+
moment.locale('fr-ca', frCaLocale);
9+
});
10+
11+
afterAll(() => {
12+
moment.locale('en');
13+
});
14+
15+
it('parse', function () {
16+
var i,
17+
_tests = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split('_');
18+
19+
function equalTest(input, mmm, i) {
20+
assertEq(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
21+
}
22+
23+
let tests: string[][] = [];
24+
for (i = 0; i < 12; i++) {
25+
tests[i] = _tests[i].split(' ');
26+
equalTest(tests[i][0], 'MMM', i);
27+
equalTest(tests[i][1], 'MMM', i);
28+
equalTest(tests[i][0], 'MMMM', i);
29+
equalTest(tests[i][1], 'MMMM', i);
30+
equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
31+
equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
32+
equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
33+
equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
34+
}
35+
});
36+
37+
it('format', function () {
38+
var a = [
39+
['dddd, MMMM Do YYYY, h:mm:ss a', 'dimanche, février 14 2010, 3:25:50 pm'],
40+
['ddd, hA', 'dim., 3PM'],
41+
['M Mo MM MMMM MMM', '2 2e 02 février févr.'],
42+
['YYYY YY', '2010 10'],
43+
['D Do DD', '14 14 14'],
44+
['d do dddd ddd dd', '0 0e dimanche dim. di'],
45+
['DDD DDDo DDDD', '45 45e 045'],
46+
['w wo ww', '6 6e 06'],
47+
['h hh', '3 03'],
48+
['H HH', '15 15'],
49+
['m mm', '25 25'],
50+
['s ss', '50 50'],
51+
['a A', 'pm PM'],
52+
['[le] Do [jour du mois]', 'le 14 jour du mois'],
53+
['[le] DDDo [jour de l’année]', 'le 45e jour de l’année'],
54+
['LTS', '15:25:50'],
55+
['L', '2010-02-14'],
56+
['LL', '14 février 2010'],
57+
['LLL', '14 février 2010 15:25'],
58+
['LLLL', 'dimanche 14 février 2010 15:25'],
59+
['l', '2010-2-14'],
60+
['ll', '14 févr. 2010'],
61+
['lll', '14 févr. 2010 15:25'],
62+
['llll', 'dim. 14 févr. 2010 15:25']
63+
],
64+
b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
65+
i;
66+
67+
for (i = 0; i < a.length; i++) {
68+
assertEq(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
69+
}
70+
});
71+
72+
it('format ordinal', function () {
73+
assertEq(moment([2017, 0, 1]).format('Mo'), '1er', '1er');
74+
assertEq(moment([2017, 1, 1]).format('Mo'), '2e', '2e');
75+
76+
assertEq(moment([2017, 0, 1]).format('Qo'), '1er', '1er');
77+
assertEq(moment([2017, 3, 1]).format('Qo'), '2e', '2e');
78+
79+
assertEq(moment([2017, 0, 1]).format('Do'), '1er', '1er');
80+
assertEq(moment([2017, 0, 2]).format('Do'), '2', '2');
81+
82+
assertEq(moment([2011, 0, 1]).format('DDDo'), '1er', '1er');
83+
assertEq(moment([2011, 0, 2]).format('DDDo'), '2e', '2e');
84+
assertEq(moment([2011, 0, 3]).format('DDDo'), '3e', '3e');
85+
assertEq(moment([2011, 0, 4]).format('DDDo'), '4e', '4e');
86+
assertEq(moment([2011, 0, 5]).format('DDDo'), '5e', '5e');
87+
assertEq(moment([2011, 0, 6]).format('DDDo'), '6e', '6e');
88+
assertEq(moment([2011, 0, 7]).format('DDDo'), '7e', '7e');
89+
assertEq(moment([2011, 0, 8]).format('DDDo'), '8e', '8e');
90+
assertEq(moment([2011, 0, 9]).format('DDDo'), '9e', '9e');
91+
assertEq(moment([2011, 0, 10]).format('DDDo'), '10e', '10e');
92+
93+
assertEq(moment([2011, 0, 11]).format('DDDo'), '11e', '11e');
94+
assertEq(moment([2011, 0, 12]).format('DDDo'), '12e', '12e');
95+
assertEq(moment([2011, 0, 13]).format('DDDo'), '13e', '13e');
96+
assertEq(moment([2011, 0, 14]).format('DDDo'), '14e', '14e');
97+
assertEq(moment([2011, 0, 15]).format('DDDo'), '15e', '15e');
98+
assertEq(moment([2011, 0, 16]).format('DDDo'), '16e', '16e');
99+
assertEq(moment([2011, 0, 17]).format('DDDo'), '17e', '17e');
100+
assertEq(moment([2011, 0, 18]).format('DDDo'), '18e', '18e');
101+
assertEq(moment([2011, 0, 19]).format('DDDo'), '19e', '19e');
102+
assertEq(moment([2011, 0, 20]).format('DDDo'), '20e', '20e');
103+
104+
assertEq(moment([2011, 0, 21]).format('DDDo'), '21e', '21e');
105+
assertEq(moment([2011, 0, 22]).format('DDDo'), '22e', '22e');
106+
assertEq(moment([2011, 0, 23]).format('DDDo'), '23e', '23e');
107+
assertEq(moment([2011, 0, 24]).format('DDDo'), '24e', '24e');
108+
assertEq(moment([2011, 0, 25]).format('DDDo'), '25e', '25e');
109+
assertEq(moment([2011, 0, 26]).format('DDDo'), '26e', '26e');
110+
assertEq(moment([2011, 0, 27]).format('DDDo'), '27e', '27e');
111+
assertEq(moment([2011, 0, 28]).format('DDDo'), '28e', '28e');
112+
assertEq(moment([2011, 0, 29]).format('DDDo'), '29e', '29e');
113+
assertEq(moment([2011, 0, 30]).format('DDDo'), '30e', '30e');
114+
115+
assertEq(moment([2011, 0, 31]).format('DDDo'), '31e', '31e');
116+
117+
assertEq(moment([2017, 0, 1]).format('do'), '0e', '0e');
118+
assertEq(moment([2017, 0, 2]).format('do'), '1er', '1er');
119+
120+
assertEq(moment([2017, 0, 4]).format('wo Wo'), '1re 1re', '1re 1re');
121+
assertEq(moment([2017, 0, 11]).format('wo Wo'), '2e 2e', '2e 2e');
122+
});
123+
124+
it('format month', function () {
125+
var i,
126+
expected = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split('_');
127+
128+
for (i = 0; i < expected.length; i++) {
129+
assertEq(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
130+
}
131+
});
132+
133+
it('format week', function () {
134+
var i,
135+
expected = 'dimanche dim. di_lundi lun. lu_mardi mar. ma_mercredi mer. me_jeudi jeu. je_vendredi ven. ve_samedi sam. sa'.split('_');
136+
137+
for (i = 0; i < expected.length; i++) {
138+
assertEq(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
139+
}
140+
});
141+
142+
it('from', function () {
143+
var start = moment([2007, 1, 28]);
144+
145+
assertEq(start.from(moment([2007, 1, 28]).add({ s: 44 }), true), 'quelques secondes', '44 seconds = a few seconds');
146+
assertEq(start.from(moment([2007, 1, 28]).add({ s: 45 }), true), 'une minute', '45 seconds = a minute');
147+
assertEq(start.from(moment([2007, 1, 28]).add({ s: 89 }), true), 'une minute', '89 seconds = a minute');
148+
assertEq(start.from(moment([2007, 1, 28]).add({ s: 90 }), true), '2 minutes', '90 seconds = 2 minutes');
149+
assertEq(start.from(moment([2007, 1, 28]).add({ m: 44 }), true), '44 minutes', '44 minutes = 44 minutes');
150+
assertEq(start.from(moment([2007, 1, 28]).add({ m: 45 }), true), 'une heure', '45 minutes = an hour');
151+
assertEq(start.from(moment([2007, 1, 28]).add({ m: 89 }), true), 'une heure', '89 minutes = an hour');
152+
assertEq(start.from(moment([2007, 1, 28]).add({ m: 90 }), true), '2 heures', '90 minutes = 2 hours');
153+
assertEq(start.from(moment([2007, 1, 28]).add({ h: 5 }), true), '5 heures', '5 hours = 5 hours');
154+
assertEq(start.from(moment([2007, 1, 28]).add({ h: 21 }), true), '21 heures', '21 hours = 21 hours');
155+
assertEq(start.from(moment([2007, 1, 28]).add({ h: 22 }), true), 'un jour', '22 hours = a day');
156+
assertEq(start.from(moment([2007, 1, 28]).add({ h: 35 }), true), 'un jour', '35 hours = a day');
157+
assertEq(start.from(moment([2007, 1, 28]).add({ h: 36 }), true), '2 jours', '36 hours = 2 days');
158+
assertEq(start.from(moment([2007, 1, 28]).add({ d: 1 }), true), 'un jour', '1 day = a day');
159+
assertEq(start.from(moment([2007, 1, 28]).add({ d: 5 }), true), '5 jours', '5 days = 5 days');
160+
assertEq(start.from(moment([2007, 1, 28]).add({ d: 25 }), true), '25 jours', '25 days = 25 days');
161+
assertEq(start.from(moment([2007, 1, 28]).add({ d: 26 }), true), 'un mois', '26 days = a month');
162+
assertEq(start.from(moment([2007, 1, 28]).add({ d: 30 }), true), 'un mois', '30 days = a month');
163+
assertEq(start.from(moment([2007, 1, 28]).add({ d: 43 }), true), 'un mois', '43 days = a month');
164+
assertEq(start.from(moment([2007, 1, 28]).add({ d: 46 }), true), '2 mois', '46 days = 2 months');
165+
assertEq(start.from(moment([2007, 1, 28]).add({ d: 74 }), true), '2 mois', '75 days = 2 months');
166+
assertEq(start.from(moment([2007, 1, 28]).add({ d: 76 }), true), '3 mois', '76 days = 3 months');
167+
assertEq(start.from(moment([2007, 1, 28]).add({ M: 1 }), true), 'un mois', '1 month = a month');
168+
assertEq(start.from(moment([2007, 1, 28]).add({ M: 5 }), true), '5 mois', '5 months = 5 months');
169+
assertEq(start.from(moment([2007, 1, 28]).add({ d: 345 }), true), 'un an', '345 days = a year');
170+
assertEq(start.from(moment([2007, 1, 28]).add({ d: 548 }), true), '2 ans', '548 days = 2 years');
171+
assertEq(start.from(moment([2007, 1, 28]).add({ y: 1 }), true), 'un an', '1 year = a year');
172+
assertEq(start.from(moment([2007, 1, 28]).add({ y: 5 }), true), '5 ans', '5 years = 5 years');
173+
});
174+
175+
it('suffix', function () {
176+
assertEq(moment(30000).from(0), 'dans quelques secondes', 'prefix');
177+
assertEq(moment(0).from(30000), 'il y a quelques secondes', 'suffix');
178+
});
179+
180+
it('fromNow', function () {
181+
assertEq(moment().add({ s: 30 }).fromNow(), 'dans quelques secondes', 'in a few seconds');
182+
assertEq(moment().add({ d: 5 }).fromNow(), 'dans 5 jours', 'in 5 days');
183+
});
184+
185+
it('same day', function () {
186+
var a = moment().hours(12).minutes(0).seconds(0);
187+
188+
assertEq(moment(a).calendar(), 'Aujourd’hui à 12:00', 'Today at the same time');
189+
assertEq(moment(a).add({ m: 25 }).calendar(), 'Aujourd’hui à 12:25', 'Now plus 25 min');
190+
assertEq(moment(a).add({ h: 1 }).calendar(), 'Aujourd’hui à 13:00', 'Now plus 1 hour');
191+
assertEq(moment(a).add({ d: 1 }).calendar(), 'Demain à 12:00', 'Tomorrow at the same time');
192+
assertEq(moment(a).subtract({ h: 1 }).calendar(), 'Aujourd’hui à 11:00', 'Now minus 1 hour');
193+
assertEq(moment(a).subtract({ d: 1 }).calendar(), 'Hier à 12:00', 'Yesterday at the same time');
194+
});
195+
196+
it('same next week', function () {
197+
var i, m;
198+
199+
for (i = 2; i < 7; i++) {
200+
m = moment().add({ d: i });
201+
assertEq(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days current time');
202+
m.hours(0).minutes(0).seconds(0).milliseconds(0);
203+
assertEq(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days beginning of day');
204+
m.hours(23).minutes(59).seconds(59).milliseconds(999);
205+
assertEq(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days end of day');
206+
}
207+
});
208+
209+
it('same last week', function () {
210+
var i, m;
211+
212+
for (i = 2; i < 7; i++) {
213+
m = moment().subtract({ d: i });
214+
assertEq(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days current time');
215+
m.hours(0).minutes(0).seconds(0).milliseconds(0);
216+
assertEq(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days beginning of day');
217+
m.hours(23).minutes(59).seconds(59).milliseconds(999);
218+
assertEq(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days end of day');
219+
}
220+
});
221+
222+
it('same all else', function () {
223+
var weeksAgo = moment().subtract({ w: 1 }),
224+
weeksFromNow = moment().add({ w: 1 });
225+
226+
assertEq(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
227+
assertEq(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
228+
229+
weeksAgo = moment().subtract({ w: 2 });
230+
weeksFromNow = moment().add({ w: 2 });
231+
232+
assertEq(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
233+
assertEq(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
234+
});
235+
236+
it('weeks year starting sunday formatted', function () {
237+
assertEq(moment([2012, 0, 1]).format('w ww wo'), '52 52 52e', 'Jan 1 2012 should be week 52');
238+
assertEq(moment([2012, 0, 2]).format('w ww wo'), '1 01 1re', 'Jan 2 2012 should be week 1');
239+
assertEq(moment([2012, 0, 8]).format('w ww wo'), '1 01 1re', 'Jan 8 2012 should be week 1');
240+
assertEq(moment([2012, 0, 9]).format('w ww wo'), '2 02 2e', 'Jan 9 2012 should be week 2');
241+
assertEq(moment([2012, 0, 15]).format('w ww wo'), '2 02 2e', 'Jan 15 2012 should be week 2');
242+
});
243+
});

src/locale/public_api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export { esUsLocale } from 'ngx-bootstrap/chronos';
1212
export { etLocale } from 'ngx-bootstrap/chronos';
1313
export { fiLocale } from 'ngx-bootstrap/chronos';
1414
export { frLocale } from 'ngx-bootstrap/chronos';
15+
export {frCaLocale} from 'ngx-bootstrap/chronos';
1516
export { glLocale } from 'ngx-bootstrap/chronos';
1617
export { heLocale } from 'ngx-bootstrap/chronos';
1718
export { hiLocale } from 'ngx-bootstrap/chronos';

src/schematics/src/ng-add/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
import { workspaces } from '@angular-devkit/core';
9-
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
9+
import { Rule, SchematicContext, SchematicsException, Tree } from '@angular-devkit/schematics';
1010
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
11-
import { getAppModulePath } from '@schematics/angular/utility/ng-ast-utils';
11+
import { getAppModulePath, isStandaloneApp } from '@schematics/angular/utility/ng-ast-utils';
1212
import { addModuleImportToRootModule, addPackageToPackageJson } from '../utils';
1313
import { hasNgModuleImport } from '../utils/ng-module-imports';
1414
import { getProjectMainFile } from '../utils/project-main-file';
@@ -85,6 +85,11 @@ function addModuleOfComponent(project: workspaces.ProjectDefinition, host: Tree,
8585
return;
8686
}
8787

88+
if (isStandaloneApp(host, getProjectMainFile(project))) {
89+
throw new SchematicsException(`ngx-bootstrap doesn't support moduleless approach if we couldn't find
90+
your starting *.module.ts learn more here https://valor-software.com/ngx-bootstrap/#/documentation#installation`);
91+
}
92+
8893
const appModulePath = getAppModulePath(host, getProjectMainFile(project));
8994
if (componentName && components[componentName]) {
9095
if (hasNgModuleImport(host, appModulePath, components[componentName].moduleName)) {

0 commit comments

Comments
 (0)