@brightspace-ui/intl 3.31.5 → 3.32.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/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.
@@ -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.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",