@brightspace-ui/intl 3.42.3 → 3.43.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/lang/pl.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "intl-common:actions:add": "Dodaj", // add action (in Title Case)
3
- "intl-common:actions:apply": "Aplikuj", // apply action (in Title Case)
3
+ "intl-common:actions:apply": "Zastosuj", // apply action (in Title Case)
4
4
  "intl-common:actions:browse": "Przeglądaj", // browse action (in Title Case)
5
5
  "intl-common:actions:cancel": "Anuluj", // cancel action (in Title Case)
6
6
  "intl-common:actions:clear": "Wyczyść", // clear action (in Title Case)
@@ -9,9 +9,9 @@ export default {
9
9
  "intl-common:actions:copy": "Kopia", // copy action (in Title Case)
10
10
  "intl-common:actions:create": "Utwórz", // create action (in Title Case)
11
11
  "intl-common:actions:delete": "Usuń", // delete action (in Title Case)
12
- "intl-common:actions:done": "Wykonane", // done action (in Title Case)
12
+ "intl-common:actions:done": "Gotowe", // done action (in Title Case)
13
13
  "intl-common:actions:edit": "Edytuj", // edit action (in Title Case)
14
- "intl-common:actions:finish": "Zakończenie", // finish action (in Title Case)
14
+ "intl-common:actions:finish": "Zakończ", // finish action (in Title Case)
15
15
  "intl-common:actions:more": "Więcej", // more action (in Title Case)
16
16
  "intl-common:actions:print": "Drukuj", // print action (in Title Case)
17
17
  "intl-common:actions:reload": "Reload", // reload action (in Title Case)
@@ -19,10 +19,10 @@ export default {
19
19
  "intl-common:actions:save": "Zapisz", // save action (in Title Case)
20
20
  "intl-common:actions:saveAndClose": "Zapisz i zamknij", // save and close action (in Title Case)
21
21
  "intl-common:actions:saveAndNew": "Zapisz i utwórz nowy", // save and new action (in Title Case)
22
- "intl-common:actions:search": "Wyszukiwanie", // search action (in Title Case)
22
+ "intl-common:actions:search": "Wyszukaj", // search action (in Title Case)
23
23
  "intl-common:actions:submit": "Prześlij", // submit action (in Title Case)
24
24
  "intl-common:actions:update": "Aktualizuj", // update action (in Title Case)
25
- "intl-common:characters:ampersand": "ampersand", // short name or description of the "&" character
25
+ "intl-common:characters:ampersand": "Ampersand", // short name or description of the "&" character
26
26
  "intl-common:characters:apostrophe": "apostrof", // short name or description of the "'" character
27
27
  "intl-common:characters:asterisk": "gwiazdka", // short name or description of the "*" character
28
28
  "intl-common:characters:backslash": "ukośnik wsteczny", // short name or description of the "\" character
@@ -30,7 +30,7 @@ export default {
30
30
  "intl-common:characters:comma": "przecinek", // short name or description of the "," character
31
31
  "intl-common:characters:greaterThan": "znak większości", // short name or description of the ">" character
32
32
  "intl-common:characters:lessThan": "znak mniejszości", // short name or description of the "<" character
33
- "intl-common:characters:numberSign": "znak numeryczny", // short name or description of the "#" character
33
+ "intl-common:characters:numberSign": "kratka", // short name or description of the "#" character
34
34
  "intl-common:characters:percentSign": "znak procentowy", // short name or description of the "%" character
35
35
  "intl-common:characters:pipe": "pionowa kreska", // short name or description of the "|" character
36
36
  "intl-common:characters:questionMark": "znak zapytania", // short name or description of the "?" character
package/lang/ru.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export default {
2
2
  "intl-common:actions:add": "Добавить", // add action (in Title Case)
3
3
  "intl-common:actions:apply": "Применить", // apply action (in Title Case)
4
- "intl-common:actions:browse": "Просматривать", // browse action (in Title Case)
4
+ "intl-common:actions:browse": "Просмотреть", // browse action (in Title Case)
5
5
  "intl-common:actions:cancel": "Отменить", // cancel action (in Title Case)
6
6
  "intl-common:actions:clear": "Очистить", // clear action (in Title Case)
7
7
  "intl-common:actions:close": "Закрыть", // close action (in Title Case)
@@ -11,9 +11,9 @@ export default {
11
11
  "intl-common:actions:delete": "Удалить", // delete action (in Title Case)
12
12
  "intl-common:actions:done": "Выполнено", // done action (in Title Case)
13
13
  "intl-common:actions:edit": "Редактировать", // edit action (in Title Case)
14
- "intl-common:actions:finish": "Готово", // finish action (in Title Case)
14
+ "intl-common:actions:finish": "Завершить", // finish action (in Title Case)
15
15
  "intl-common:actions:more": "Подробнее", // more action (in Title Case)
16
- "intl-common:actions:print": "Распечатать", // print action (in Title Case)
16
+ "intl-common:actions:print": "Печать", // print action (in Title Case)
17
17
  "intl-common:actions:reload": "Reload", // reload action (in Title Case)
18
18
  "intl-common:actions:remove": "Удалить", // remove action (in Title Case)
19
19
  "intl-common:actions:save": "Сохранить", // save action (in Title Case)
@@ -28,7 +28,7 @@ export default {
28
28
  "intl-common:characters:backslash": "Обратная косая черта", // short name or description of the "\" character
29
29
  "intl-common:characters:colon": "Двоеточие", // short name or description of the ":" character
30
30
  "intl-common:characters:comma": "запятая", // short name or description of the "," character
31
- "intl-common:characters:greaterThan": "Знак «больше»", // short name or description of the ">" character
31
+ "intl-common:characters:greaterThan": "знак «больше»", // short name or description of the ">" character
32
32
  "intl-common:characters:lessThan": "знак «меньше»", // short name or description of the "<" character
33
33
  "intl-common:characters:numberSign": "символ номера", // short name or description of the "#" character
34
34
  "intl-common:characters:percentSign": "знак процента", // short name or description of the "%" character
@@ -41,5 +41,5 @@ export default {
41
41
  "intl-common:navigation:back:title": "Назад", // term for navigating back to the previous page (in Title Case)
42
42
  "intl-common:navigation:continue:title": "Продолжить", // continue action (in Title Case)
43
43
  "intl-common:navigation:next:title": "Далее", // term for navigating to the next page or item (in Title Case)
44
- "intl-common:navigation:previous:title": "Предыдущая", // term for navigating to the previous page or item (in Title Case)
44
+ "intl-common:navigation:previous:title": "Назад", // term for navigating to the previous page or item (in Title Case)
45
45
  };
package/lib/dateTime.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { getDocumentLocaleSettings, merge } from './common.js';
2
+ import { formatDateTimeSkeleton } from './dateTimeSkeleton.js';
2
3
  import { localeData } from './locale-data/current.js';
3
4
  import { resolveSupportedLocale } from './locale-data/supported.js';
4
5
 
@@ -869,12 +870,13 @@ export function getDateTimeDescriptor() {
869
870
  });
870
871
  }
871
872
 
872
- export function formatTime(date, options) {
873
+ export function formatTime(date, options = {}) {
874
+
875
+ if (options.skeleton) return formatDateTimeSkeleton(date, options, { date: false });
873
876
 
874
877
  const descriptor = getDateTimeDescriptor();
875
878
  const settings = getDocumentLocaleSettings();
876
879
 
877
- options = options || {};
878
880
  const timezone = options.timezone || settings.timezone.name;
879
881
  const format = descriptor.formats.timeFormats[options.format]
880
882
  || options.format || descriptor.formats.timeFormats['short'];
@@ -966,11 +968,12 @@ export function parseTime(input, options) {
966
968
 
967
969
  }
968
970
 
969
- export function formatDate(date, options) {
971
+ export function formatDate(date, options = {}) {
972
+
973
+ if (options.skeleton) return formatDateTimeSkeleton(date, options, { time: false });
970
974
 
971
975
  const descriptor = getDateTimeDescriptor();
972
976
 
973
- options = options || {};
974
977
  options.format = options.format || 'short';
975
978
 
976
979
  let format = descriptor.formats.dateFormats[options.format];
@@ -1049,9 +1052,10 @@ export function parseDate(input) {
1049
1052
 
1050
1053
  }
1051
1054
 
1052
- export function formatDateTime(date, options) {
1055
+ export function formatDateTime(date, options = {}) {
1056
+
1057
+ if (options.skeleton) return formatDateTimeSkeleton(date, options);
1053
1058
 
1054
- options = options || {};
1055
1059
  const format = options.format || 'short';
1056
1060
 
1057
1061
  switch (format) {
@@ -0,0 +1,74 @@
1
+ import { getDocumentLocaleSettings } from './common.js';
2
+ import IntlMessageFormat from 'intl-messageformat';
3
+ import { localeData } from './locale-data/current.js';
4
+
5
+ const documentLocaleSettings = getDocumentLocaleSettings();
6
+
7
+ export function formatDateTimeSkeleton(dateTime, options = {}) {
8
+ const { date = true, time = true, locale } = arguments[2] || {};
9
+
10
+ const {
11
+ timezone: timeZone =
12
+ options.timeZone
13
+ || documentLocaleSettings.timezone.identifier
14
+ || undefined,
15
+ timeZoneName,
16
+ hourCycle
17
+ } = options;
18
+ let {
19
+ format,
20
+ skeleton = '',
21
+ } = options;
22
+
23
+ if (!skeleton) {
24
+ if (date) {
25
+ if (!format || format === 'short') {
26
+ skeleton = localeData.dateFormats.short;
27
+ }
28
+ else if (format === 'medium') {
29
+ skeleton = localeData.dateFormats.medium;
30
+ }
31
+ else if (format === 'full') {
32
+ skeleton = localeData.dateFormats.full;
33
+ }
34
+ }
35
+ if (time) {
36
+ skeleton += localeData.timeFormats.short;
37
+ }
38
+
39
+ if (!skeleton) {
40
+ console.warn(`"${format}" is not a valid format`);
41
+ return;
42
+ }
43
+
44
+ format = null;
45
+ } else {
46
+ if (!options.forceUnsupportedFormat) {
47
+ throw 'Use skeletons only if standard supported formats are inarguably insufficient. You must explicitly opt in with the `forceUnsupportedFormat` option.';
48
+ }
49
+
50
+ if (/[HhKkJYuUrM]|j{2,}/.test(skeleton)) {
51
+ console.warn('Replacing static hour symbols: H/h/K/k/J/jj -> j');
52
+ skeleton = skeleton.replace(/[HhKkJj]+/g, 'j');
53
+ }
54
+ if (!time) skeleton = skeleton.replace(/[HhJjKkmsaZzVvSsBbAOXx]/g, '');
55
+ if (!date) skeleton = skeleton.replace(/[GyYuUrQqMLwWdDFgEec]/g, '');
56
+ }
57
+
58
+ if (!format && !skeleton) {
59
+ throw 'No format or skeleton provided. Did you disable `dates` and `times`?';
60
+ }
61
+ const msg = `{dateTime, date, ${format || `::${skeleton}`}}`;
62
+
63
+ const formatters = {
64
+ getDateTimeFormat(locale, opts) {
65
+ return new Intl.DateTimeFormat(locale, {
66
+ ...opts,
67
+ ...{ timeZone, timeZoneName, hourCycle }
68
+ });
69
+ }
70
+ };
71
+ const dateFormatter = new IntlMessageFormat(msg, locale || documentLocaleSettings.language, null, { formatters });
72
+ const formatted = dateFormatter.format({ dateTime });
73
+ return formatted;
74
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/intl",
3
- "version": "3.42.3",
3
+ "version": "3.43.0",
4
4
  "description": "Internationalization APIs for number, date, time and file size formatting and parsing in D2L Brightspace.",
5
5
  "main": "lib/number.js",
6
6
  "type": "module",