@brightspace-ui/intl 3.20.0 → 3.21.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.
Files changed (2) hide show
  1. package/lib/localize.js +8 -5
  2. package/package.json +1 -1
package/lib/localize.js CHANGED
@@ -156,10 +156,8 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
156
156
  }
157
157
  if (Object.prototype.hasOwnProperty.call(this, 'getLocalizeResources') || Object.prototype.hasOwnProperty.call(this, 'resources')) {
158
158
  const possibleLanguages = this._generatePossibleLanguages(config);
159
- if (config?.importFunc) {
160
- const resourcesPromise = this.getLocalizeResources(possibleLanguages, config);
161
- resourcesLoadedPromises.push(resourcesPromise);
162
- }
159
+ const resourcesPromise = this.getLocalizeResources(possibleLanguages, config);
160
+ resourcesLoadedPromises.push(resourcesPromise);
163
161
  if (config?.loadCommon) {
164
162
  resourcesLoadedPromises.push(this.getLocalizeResources(possibleLanguages, {
165
163
  importFunc: async(lang) => {
@@ -177,6 +175,8 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
177
175
 
178
176
  static async _getLocalizeResources(langs, { importFunc, osloCollection, useBrowserLangs }) {
179
177
 
178
+ if (importFunc === undefined) return;
179
+
180
180
  // in dev, don't request unsupported langpacks
181
181
  if (!importFunc.toString().includes('switch') && !useBrowserLangs) {
182
182
  langs = langs.filter(lang => supportedLangpacks.includes(lang));
@@ -213,12 +213,15 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
213
213
 
214
214
  const resourcesPromise = this.constructor._getAllLocalizeResources(this.config);
215
215
  this.#resourcesPromise = resourcesPromise;
216
- const localizeResources = (await resourcesPromise).flat(Infinity);
216
+ const localizeResources = (await resourcesPromise)
217
+ .flat(Infinity)
218
+ .filter(e => e);
217
219
  // If the locale changed while resources were being fetched, abort
218
220
  if (this.#resourcesPromise !== resourcesPromise) return;
219
221
 
220
222
  const allResources = {};
221
223
  const resolvedLocales = new Set();
224
+
222
225
  for (const { language, resources } of localizeResources) {
223
226
  for (const [name, value] of Object.entries(resources)) {
224
227
  allResources[name] = { language, value };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/intl",
3
- "version": "3.20.0",
3
+ "version": "3.21.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",