@wix/form-public 0.579.0 → 0.580.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/dist/index.cjs CHANGED
@@ -52131,12 +52131,38 @@ async function loadFieldViewerTranslations(locale) {
52131
52131
  }
52132
52132
  }
52133
52133
  }
52134
- var getLocaleDatasetTranslationsUrl = (locale = "en") => `https://static.parastorage.com/services/locale-dataset-data/1.4213.0/translations/messages_${locale}.json`;
52134
+ var LOCALE_DATASET_DATA_VERSION = "1.4238.0";
52135
+ var FALLBACK_LOCALE = "en";
52136
+ var getLocaleDatasetTranslationsUrl = (locale = FALLBACK_LOCALE) => `https://static.parastorage.com/services/locale-dataset-data/${LOCALE_DATASET_DATA_VERSION}/translations/messages_${locale}.json`;
52137
+ var fetchJson = async (url) => {
52138
+ const response = await fetch(url);
52139
+ if (!response.ok) {
52140
+ throw new Error(`Request to ${url} failed with status ${response.status}`);
52141
+ }
52142
+ return response.json();
52143
+ };
52135
52144
  var fetchLocaleDatasetTranslations = async (locale) => {
52136
- const url = getLocaleDatasetTranslationsUrl(locale);
52137
- const fallbackUrl = getLocaleDatasetTranslationsUrl();
52138
- const response = await fetch(url).catch(() => fetch(fallbackUrl));
52139
- return response?.json() ?? {};
52145
+ try {
52146
+ return await fetchJson(getLocaleDatasetTranslationsUrl(locale));
52147
+ } catch (error) {
52148
+ if (locale === FALLBACK_LOCALE) {
52149
+ console.warn("Failed to load locale dataset translations", error);
52150
+ return {};
52151
+ }
52152
+ console.warn(
52153
+ `Failed to load locale dataset translations for locale ${locale}, falling back to English`,
52154
+ error
52155
+ );
52156
+ try {
52157
+ return await fetchJson(getLocaleDatasetTranslationsUrl(FALLBACK_LOCALE));
52158
+ } catch (fallbackError) {
52159
+ console.warn(
52160
+ "Failed to load English locale dataset translations",
52161
+ fallbackError
52162
+ );
52163
+ return {};
52164
+ }
52165
+ }
52140
52166
  };
52141
52167
  async function createI18n(locale) {
52142
52168
  const i18nInstance = default2__default.default.createInstance();
@@ -52173,10 +52199,20 @@ var FormProvider = ({
52173
52199
  React178.useEffect(() => {
52174
52200
  const initializeI18n = async () => {
52175
52201
  try {
52176
- const newI18n = await createI18n(locale);
52177
- setI18nInstance(newI18n);
52202
+ setI18nInstance(await createI18n(locale));
52178
52203
  } catch (error) {
52179
52204
  console.error("Failed to initialize i18n:", error);
52205
+ if (locale === "en") {
52206
+ return;
52207
+ }
52208
+ try {
52209
+ setI18nInstance(await createI18n("en"));
52210
+ } catch (fallbackError) {
52211
+ console.error(
52212
+ "Failed to initialize i18n with English fallback:",
52213
+ fallbackError
52214
+ );
52215
+ }
52180
52216
  }
52181
52217
  };
52182
52218
  initializeI18n();