@brightspace-ui/intl 3.31.4 → 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.
package/lang/vi.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export default {
2
2
  "intl-common:actions:add": "Thêm", // add action (in Title Case)
3
3
  "intl-common:actions:apply": "Áp dụng", // apply action (in Title Case)
4
- "intl-common:actions:browse": "Xem thêm", // browse action (in Title Case)
4
+ "intl-common:actions:browse": "Duyệt qua", // browse action (in Title Case)
5
5
  "intl-common:actions:cancel": "Hủy", // cancel action (in Title Case)
6
6
  "intl-common:actions:clear": "Xóa", // clear action (in Title Case)
7
7
  "intl-common:actions:close": "Đóng", // close action (in Title Case)
@@ -11,12 +11,12 @@ export default {
11
11
  "intl-common:actions:delete": "Xóa", // delete action (in Title Case)
12
12
  "intl-common:actions:done": "Hoàn tất", // done action (in Title Case)
13
13
  "intl-common:actions:edit": "Chỉnh sửa", // edit action (in Title Case)
14
- "intl-common:actions:finish": "Xông", // finish action (in Title Case)
14
+ "intl-common:actions:finish": "Xong", // finish action (in Title Case)
15
15
  "intl-common:actions:print": "In", // print action (in Title Case)
16
16
  "intl-common:actions:remove": "Loại bỏ", // remove action (in Title Case)
17
17
  "intl-common:actions:save": "Lưu", // save action (in Title Case)
18
18
  "intl-common:actions:saveAndClose": "Lưu và đóng", // save and close action (in Title Case)
19
- "intl-common:actions:saveAndNew": "Lưu và Tạo mới", // save and new action (in Title Case)
19
+ "intl-common:actions:saveAndNew": "Lưu và tạo mới", // save and new action (in Title Case)
20
20
  "intl-common:actions:search": "Tìm kiếm", // search action (in Title Case)
21
21
  "intl-common:actions:submit": "Gửi", // submit action (in Title Case)
22
22
  "intl-common:actions:update": "Cập nhật", // update action (in Title Case)
@@ -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.4",
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",