@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.js CHANGED
@@ -52121,12 +52121,38 @@ async function loadFieldViewerTranslations(locale) {
52121
52121
  }
52122
52122
  }
52123
52123
  }
52124
- var getLocaleDatasetTranslationsUrl = (locale = "en") => `https://static.parastorage.com/services/locale-dataset-data/1.4213.0/translations/messages_${locale}.json`;
52124
+ var LOCALE_DATASET_DATA_VERSION = "1.4238.0";
52125
+ var FALLBACK_LOCALE = "en";
52126
+ var getLocaleDatasetTranslationsUrl = (locale = FALLBACK_LOCALE) => `https://static.parastorage.com/services/locale-dataset-data/${LOCALE_DATASET_DATA_VERSION}/translations/messages_${locale}.json`;
52127
+ var fetchJson = async (url) => {
52128
+ const response = await fetch(url);
52129
+ if (!response.ok) {
52130
+ throw new Error(`Request to ${url} failed with status ${response.status}`);
52131
+ }
52132
+ return response.json();
52133
+ };
52125
52134
  var fetchLocaleDatasetTranslations = async (locale) => {
52126
- const url = getLocaleDatasetTranslationsUrl(locale);
52127
- const fallbackUrl = getLocaleDatasetTranslationsUrl();
52128
- const response = await fetch(url).catch(() => fetch(fallbackUrl));
52129
- return response?.json() ?? {};
52135
+ try {
52136
+ return await fetchJson(getLocaleDatasetTranslationsUrl(locale));
52137
+ } catch (error) {
52138
+ if (locale === FALLBACK_LOCALE) {
52139
+ console.warn("Failed to load locale dataset translations", error);
52140
+ return {};
52141
+ }
52142
+ console.warn(
52143
+ `Failed to load locale dataset translations for locale ${locale}, falling back to English`,
52144
+ error
52145
+ );
52146
+ try {
52147
+ return await fetchJson(getLocaleDatasetTranslationsUrl(FALLBACK_LOCALE));
52148
+ } catch (fallbackError) {
52149
+ console.warn(
52150
+ "Failed to load English locale dataset translations",
52151
+ fallbackError
52152
+ );
52153
+ return {};
52154
+ }
52155
+ }
52130
52156
  };
52131
52157
  async function createI18n(locale) {
52132
52158
  const i18nInstance = default2.createInstance();
@@ -52163,10 +52189,20 @@ var FormProvider = ({
52163
52189
  useEffect(() => {
52164
52190
  const initializeI18n = async () => {
52165
52191
  try {
52166
- const newI18n = await createI18n(locale);
52167
- setI18nInstance(newI18n);
52192
+ setI18nInstance(await createI18n(locale));
52168
52193
  } catch (error) {
52169
52194
  console.error("Failed to initialize i18n:", error);
52195
+ if (locale === "en") {
52196
+ return;
52197
+ }
52198
+ try {
52199
+ setI18nInstance(await createI18n("en"));
52200
+ } catch (fallbackError) {
52201
+ console.error(
52202
+ "Failed to initialize i18n with English fallback:",
52203
+ fallbackError
52204
+ );
52205
+ }
52170
52206
  }
52171
52207
  };
52172
52208
  initializeI18n();