@brightspace-ui/intl 3.21.0 → 3.21.2
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/helpers/getLocalizeResources.js +1 -1
- package/lib/PluralRules.js +0 -2
- package/lib/common.js +1 -1
- package/lib/localize.js +5 -8
- package/package.json +4 -4
package/lib/PluralRules.js
CHANGED
|
@@ -52,11 +52,9 @@ class PluralRules extends Intl.PluralRules {
|
|
|
52
52
|
this.#localeData = localeData[this.#locale];
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
|
|
56
55
|
resolvedOptions() {
|
|
57
56
|
return { ...super.resolvedOptions(), ...this.#localeData?.options[this.#type] };
|
|
58
57
|
}
|
|
59
|
-
|
|
60
58
|
select(n) {
|
|
61
59
|
if (this.#localeData) {
|
|
62
60
|
return this.#localeData.select(n, this.#type === 'ordinal');
|
package/lib/common.js
CHANGED
package/lib/localize.js
CHANGED
|
@@ -35,7 +35,6 @@ const noAllowedTagsRegex = getDisallowedTagsRegex([]);
|
|
|
35
35
|
export const getLocalizeClass = (superclass = class {}) => class LocalizeClass extends superclass {
|
|
36
36
|
|
|
37
37
|
static documentLocaleSettings = getDocumentLocaleSettings();
|
|
38
|
-
|
|
39
38
|
static setLocalizeMarkup(localizeMarkup) {
|
|
40
39
|
this.#localizeMarkup ??= localizeMarkup;
|
|
41
40
|
}
|
|
@@ -48,12 +47,10 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
|
|
|
48
47
|
this.#connected = true;
|
|
49
48
|
this.#localeChangeCallback();
|
|
50
49
|
}
|
|
51
|
-
|
|
52
50
|
disconnect() {
|
|
53
51
|
LocalizeClass.documentLocaleSettings.removeChangeListener(this.#localeChangeCallback);
|
|
54
52
|
this.#connected = false;
|
|
55
53
|
}
|
|
56
|
-
|
|
57
54
|
localize(name, replacements) {
|
|
58
55
|
|
|
59
56
|
const { language, value } = this.localize.resources?.[name] ?? {};
|
|
@@ -132,7 +129,6 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
|
|
|
132
129
|
#resourcesPromise;
|
|
133
130
|
|
|
134
131
|
__resourcesLoadedPromise = new Promise(r => this.#resolveResourcesLoaded = r);
|
|
135
|
-
|
|
136
132
|
static _generatePossibleLanguages(config) {
|
|
137
133
|
|
|
138
134
|
if (config?.useBrowserLangs) return navigator.languages.map(e => e.toLowerCase()).concat('en');
|
|
@@ -145,7 +141,6 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
|
|
|
145
141
|
|
|
146
142
|
return Array.from(new Set([ ...langs, 'en-us', 'en' ]));
|
|
147
143
|
}
|
|
148
|
-
|
|
149
144
|
static _getAllLocalizeResources(config = this.localizeConfig) {
|
|
150
145
|
const resourcesLoadedPromises = [];
|
|
151
146
|
const superCtor = Object.getPrototypeOf(this);
|
|
@@ -172,7 +167,6 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
|
|
|
172
167
|
}
|
|
173
168
|
return Promise.all(resourcesLoadedPromises);
|
|
174
169
|
}
|
|
175
|
-
|
|
176
170
|
static async _getLocalizeResources(langs, { importFunc, osloCollection, useBrowserLangs }) {
|
|
177
171
|
|
|
178
172
|
if (importFunc === undefined) return;
|
|
@@ -203,9 +197,12 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
|
|
|
203
197
|
}
|
|
204
198
|
}
|
|
205
199
|
}
|
|
206
|
-
|
|
207
200
|
_hasResources() {
|
|
208
|
-
|
|
201
|
+
if (this.constructor.localizeConfig) {
|
|
202
|
+
return this.constructor.localizeConfig !== undefined ||
|
|
203
|
+
this.constructor.localizeConfig.loadCommon === true;
|
|
204
|
+
}
|
|
205
|
+
return this.constructor.getLocalizeResources !== undefined;
|
|
209
206
|
}
|
|
210
207
|
|
|
211
208
|
async #localeChangeHandler() {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/intl",
|
|
3
|
-
"version": "3.21.
|
|
3
|
+
"version": "3.21.2",
|
|
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",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"lint": "eslint .
|
|
8
|
+
"lint": "eslint .",
|
|
9
9
|
"start": "web-dev-server --node-resolve --watch --open /demo/",
|
|
10
10
|
"test:unit": "d2l-test-runner",
|
|
11
11
|
"test": "npm run lint && npm run test:unit"
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"homepage": "https://github.com/BrightspaceUI/intl",
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@brightspace-ui/testing": "^1",
|
|
43
|
-
"eslint": "^
|
|
44
|
-
"eslint-config-brightspace": "^
|
|
43
|
+
"eslint": "^9",
|
|
44
|
+
"eslint-config-brightspace": "^2",
|
|
45
45
|
"sinon": "^19.0.2"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|