@discord/intl 0.5.1-canary.7ec6789 → 0.5.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.
@@ -206,7 +206,14 @@ var MessageLoader = /** @class */ (function () {
206
206
  // requested locale. Shouldn't happen, but throwing here is much more
207
207
  // contextual than whatever error would result otherwise.
208
208
  if (this.localeImportMap[locale] == null) {
209
- throw new Error("Requested to load locale ".concat(locale, ", which should be supported, but no source for translation data was provided."));
209
+ if (this.supportedLocales.includes(locale)) {
210
+ // `supportedLocales` is determined by the `localeImportMap`, so if it's present but
211
+ // nullish, it's almost definitely a configuration error and deserves to be reported loudly.
212
+ throw new Error("Requested to load locale ".concat(locale, ", which should be supported, but no source for translation data was provided."));
213
+ }
214
+ else {
215
+ return [2 /*return*/];
216
+ }
210
217
  }
211
218
  // If the locale is already set in `messages`, then it doesn't need to be loaded again.
212
219
  if (this.messages[locale] != null)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@discord/intl",
3
- "version": "0.5.1-canary.7ec6789",
3
+ "version": "0.5.2",
4
4
  "license": "MIT",
5
5
  "description": "Client runtime for managing messages and translations in a React project.",
6
6
  "main": "./dist/index.js",
@@ -210,9 +210,15 @@ export class MessageLoader {
210
210
  // requested locale. Shouldn't happen, but throwing here is much more
211
211
  // contextual than whatever error would result otherwise.
212
212
  if (this.localeImportMap[locale] == null) {
213
- throw new Error(
214
- `Requested to load locale ${locale}, which should be supported, but no source for translation data was provided.`,
215
- );
213
+ if (this.supportedLocales.includes(locale)) {
214
+ // `supportedLocales` is determined by the `localeImportMap`, so if it's present but
215
+ // nullish, it's almost definitely a configuration error and deserves to be reported loudly.
216
+ throw new Error(
217
+ `Requested to load locale ${locale}, which should be supported, but no source for translation data was provided.`,
218
+ );
219
+ } else {
220
+ return;
221
+ }
216
222
  }
217
223
 
218
224
  // If the locale is already set in `messages`, then it doesn't need to be loaded again.