@brightspace-ui/intl 3.42.4 → 3.44.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
@@ -14,7 +14,7 @@ export default {
14
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
- "intl-common:actions:reload": "Reload", // reload action (in Title Case)
17
+ "intl-common:actions:reload": "Odśwież", // reload action (in Title Case)
18
18
  "intl-common:actions:remove": "Usuń", // remove action (in Title Case)
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)
package/lang/ru.js CHANGED
@@ -14,7 +14,7 @@ export default {
14
14
  "intl-common:actions:finish": "Завершить", // finish action (in Title Case)
15
15
  "intl-common:actions:more": "Подробнее", // more action (in Title Case)
16
16
  "intl-common:actions:print": "Печать", // print action (in Title Case)
17
- "intl-common:actions:reload": "Reload", // reload action (in Title Case)
17
+ "intl-common:actions: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)
20
20
  "intl-common:actions:saveAndClose": "Сохранить и закрыть", // save and close action (in Title Case)
package/lang/ur.js ADDED
@@ -0,0 +1,45 @@
1
+ export default {
2
+ "intl-common:actions:add": "Add", // add action (in Title Case)
3
+ "intl-common:actions:apply": "Apply", // apply action (in Title Case)
4
+ "intl-common:actions:browse": "Browse", // browse action (in Title Case)
5
+ "intl-common:actions:cancel": "Cancel", // cancel action (in Title Case)
6
+ "intl-common:actions:clear": "Clear", // clear action (in Title Case)
7
+ "intl-common:actions:close": "Close", // close action (in Title Case)
8
+ "intl-common:actions:confirm": "Confirm", // confirm action (in Title Case)
9
+ "intl-common:actions:copy": "Copy", // copy action (in Title Case)
10
+ "intl-common:actions:create": "Create", // create action (in Title Case)
11
+ "intl-common:actions:delete": "Delete", // delete action (in Title Case)
12
+ "intl-common:actions:done": "Done", // done action (in Title Case)
13
+ "intl-common:actions:edit": "Edit", // edit action (in Title Case)
14
+ "intl-common:actions:finish": "Finish", // finish action (in Title Case)
15
+ "intl-common:actions:more": "More", // more action (in Title Case)
16
+ "intl-common:actions:print": "Print", // print action (in Title Case)
17
+ "intl-common:actions:reload": "Reload", // reload action (in Title Case)
18
+ "intl-common:actions:remove": "Remove", // remove action (in Title Case)
19
+ "intl-common:actions:save": "Save", // save action (in Title Case)
20
+ "intl-common:actions:saveAndClose": "Save and Close", // save and close action (in Title Case)
21
+ "intl-common:actions:saveAndNew": "Save and New", // save and new action (in Title Case)
22
+ "intl-common:actions:search": "Search", // search action (in Title Case)
23
+ "intl-common:actions:submit": "Submit", // submit action (in Title Case)
24
+ "intl-common:actions:update": "Update", // update action (in Title Case)
25
+ "intl-common:characters:ampersand": "ampersand", // short name or description of the "&" character
26
+ "intl-common:characters:apostrophe": "apostrophe", // short name or description of the "'" character
27
+ "intl-common:characters:asterisk": "asterisk", // short name or description of the "*" character
28
+ "intl-common:characters:backslash": "backslash", // short name or description of the "\" character
29
+ "intl-common:characters:colon": "colon", // short name or description of the ":" character
30
+ "intl-common:characters:comma": "comma", // short name or description of the "," character
31
+ "intl-common:characters:greaterThan": "greater-than sign", // short name or description of the ">" character
32
+ "intl-common:characters:lessThan": "less-than sign", // short name or description of the "<" character
33
+ "intl-common:characters:numberSign": "number sign", // short name or description of the "#" character
34
+ "intl-common:characters:percentSign": "percent sign", // short name or description of the "%" character
35
+ "intl-common:characters:pipe": "pipe", // short name or description of the "|" character
36
+ "intl-common:characters:questionMark": "question mark", // short name or description of the "?" character
37
+ "intl-common:characters:quotationMark": "quotation mark", // short name or description of the '"' character
38
+ "intl-common:confirm:no": "No", // no response to a question (in Title Case)
39
+ "intl-common:confirm:ok": "OK", // okay response to a question
40
+ "intl-common:confirm:yes": "Yes", // yes response to a question (in Title Case)
41
+ "intl-common:navigation:back:title": "Back", // term for navigating back to the previous page (in Title Case)
42
+ "intl-common:navigation:continue:title": "Continue", // continue action (in Title Case)
43
+ "intl-common:navigation:next:title": "Next", // term for navigating to the next page or item (in Title Case)
44
+ "intl-common:navigation:previous:title": "Previous", // term for navigating to the previous page or item (in Title Case)
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.4",
3
+ "version": "3.44.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",