@brightspace-ui/intl 3.31.5 → 3.32.1

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/README.md CHANGED
@@ -272,6 +272,17 @@ const separator = getSeparator({ nonBreaking: true }); // -> ',\xa0' in en-US
272
272
  Options:
273
273
  - **nonBreaking**: a Boolean flag, whether to use non-breaking spaces instead of standard spaces; default is `false`
274
274
 
275
+ ## Terminology
276
+
277
+ Use `getTerminology` to get terminology values defined by `d2l.Languages.Terminology.*` config variables.
278
+
279
+ ```javascript
280
+ import { getTerminology, TerminologyKey } from '@brightspace-ui/intl/lib/terminology.js';
281
+
282
+ // Get the terminology value defined by the d2l.Languages.Terminology.Educator config variable
283
+ const educatorTerminology = getTerminology(TerminologyKey.Educator);
284
+ ```
285
+
275
286
  ## Language Localization
276
287
 
277
288
  The `Localize` class allows text to be displayed in the user's preferred language.
package/lang/hi.js CHANGED
@@ -5,7 +5,7 @@ export default {
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)
8
- "intl-common:actions:confirm": "कन्फ़र्म करें", // confirm action (in Title Case)
8
+ "intl-common:actions:confirm": "कन्फ़र्म करें", // confirm action (in Title Case)
9
9
  "intl-common:actions:copy": "कॉपी करें", // copy action (in Title Case)
10
10
  "intl-common:actions:create": "बनाएँ", // create action (in Title Case)
11
11
  "intl-common:actions:delete": "हटाएँ", // delete action (in Title Case)
@@ -156,6 +156,10 @@ export const americaTimezones = {
156
156
  regionCode: 'MX',
157
157
  ianaSource: 'northamerica'
158
158
  },
159
+ 'America/Coral_Harbour': {
160
+ regionCode: 'CA',
161
+ ianaSource: 'northamerica'
162
+ },
159
163
  'America/Costa_Rica': {
160
164
  regionCode: 'CR',
161
165
  ianaSource: 'northamerica'
@@ -4,6 +4,11 @@ const DEFAULTS = {
4
4
  pseudoLocalization: {},
5
5
  _fallbackLanguage: null,
6
6
  overrides: {},
7
+ terminology: {
8
+ educator: 'teacher',
9
+ moduleHierarchy: 'module',
10
+ outcomes: 'standards'
11
+ },
7
12
  timezone: { name: '', identifier: '' },
8
13
  oslo: { batch: null, collection: null, version: null }
9
14
  };
@@ -83,6 +88,7 @@ export class DocumentLocaleSettings {
83
88
  this._languageInitial ??= this._language;
84
89
  this.fallbackLanguage = host.getAttribute('data-lang-default');
85
90
  this.overrides = this._tryParseHtmlElemAttr('data-intl-overrides', DEFAULTS.overrides);
91
+ this.terminology = this._tryParseHtmlElemAttr('data-terminology', DEFAULTS.terminology);
86
92
  this.timezone = this._tryParseHtmlElemAttr('data-timezone', DEFAULTS.timezone);
87
93
  this.pseudoLocalization = this._tryParseHtmlElemAttr('data-pseudo-localization', DEFAULTS.pseudoLocalization);
88
94
  this.oslo = this._tryParseHtmlElemAttr('data-oslo', DEFAULTS.oslo);
@@ -98,6 +104,9 @@ export class DocumentLocaleSettings {
98
104
  this.fallbackLanguage = host.getAttribute('data-lang-default');
99
105
  } else if (mutation.attributeName === 'data-intl-overrides') {
100
106
  this.overrides = this._tryParseHtmlElemAttr('data-intl-overrides', DEFAULTS.overrides);
107
+ } else if (mutation.attributeName === 'data-terminology') {
108
+ this.terminology = this._tryParseHtmlElemAttr('data-terminology', DEFAULTS.terminology);
109
+ localeAttributeChange = true;
101
110
  } else if (mutation.attributeName === 'data-timezone') {
102
111
  this.timezone = this._tryParseHtmlElemAttr('data-timezone', DEFAULTS.timezone);
103
112
  localeAttributeChange = true;
@@ -0,0 +1,20 @@
1
+ import { getDocumentLocaleSettings } from './common.js';
2
+
3
+ export const TerminologyKey = Object.freeze({
4
+ LearningOutcomes: 'outcomes',
5
+ Educator: 'educator',
6
+ ModuleHierarchy: 'moduleHierarchy'
7
+ });
8
+
9
+ export function getTerminology(key) {
10
+ if (!key) {
11
+ throw new TypeError('Terminology key is required.');
12
+ }
13
+ if (!Object.values(TerminologyKey).includes(key)) {
14
+ throw new TypeError(`Invalid terminology key "${key}".`);
15
+ }
16
+
17
+ const terminology = getDocumentLocaleSettings().terminology;
18
+
19
+ return terminology[key];
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/intl",
3
- "version": "3.31.5",
3
+ "version": "3.32.1",
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",
@@ -42,7 +42,7 @@
42
42
  "@brightspace-ui/testing": "^1",
43
43
  "eslint": "^9",
44
44
  "eslint-config-brightspace": "^2",
45
- "sinon": "^19.0.2"
45
+ "sinon": "^21.0.0"
46
46
  },
47
47
  "dependencies": {
48
48
  "intl-messageformat": "^10"