@wix/form-public 0.115.0 → 0.116.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.
@@ -84,6 +84,8 @@ export { DateTimeInput }
84
84
 
85
85
  export { Dropdown }
86
86
 
87
+ export declare const fetchLocaleDatasetTranslations: (locale: string) => Promise<Record<string, string>>;
88
+
87
89
  export declare const FIELD_TYPE_MAP: Record<SchemaFieldType, FieldType>;
88
90
 
89
91
  declare type FieldMap = {
@@ -84,6 +84,8 @@ export { DateTimeInput }
84
84
 
85
85
  export { Dropdown }
86
86
 
87
+ export declare const fetchLocaleDatasetTranslations: (locale: string) => Promise<Record<string, string>>;
88
+
87
89
  export declare const FIELD_TYPE_MAP: Record<SchemaFieldType, FieldType>;
88
90
 
89
91
  declare type FieldMap = {
package/dist/index.cjs CHANGED
@@ -31828,6 +31828,13 @@ async function loadFieldViewerTranslations(locale) {
31828
31828
  }
31829
31829
  }
31830
31830
  }
31831
+ var getLocaleDatasetTranslationsUrl = (locale = "en") => `https://static.parastorage.com/services/locale-dataset-data/1.4213.0/translations/messages_${locale}.json`;
31832
+ var fetchLocaleDatasetTranslations = async (locale) => {
31833
+ const url = getLocaleDatasetTranslationsUrl(locale);
31834
+ const fallbackUrl = getLocaleDatasetTranslationsUrl();
31835
+ const response = await fetch(url).catch(() => fetch(fallbackUrl));
31836
+ return response?.json() ?? {};
31837
+ };
31831
31838
  async function createI18n(locale) {
31832
31839
  const i18nInstance = i18next__default.default.createInstance();
31833
31840
  await i18nInstance.use(reactI18next.initReactI18next).init({
@@ -31844,14 +31851,12 @@ async function createI18n(locale) {
31844
31851
  ns: ["translation", FORM_VIEWER_NAMESPACE],
31845
31852
  resources: {}
31846
31853
  });
31847
- const fieldTranslations = await loadFieldViewerTranslations(locale);
31848
- i18nInstance.addResourceBundle(
31849
- locale,
31850
- FORM_VIEWER_NAMESPACE,
31851
- fieldTranslations,
31852
- true,
31853
- true
31854
- );
31854
+ const [fieldTranslations, localeDataset3] = await Promise.all([
31855
+ loadFieldViewerTranslations(locale),
31856
+ fetchLocaleDatasetTranslations(locale)
31857
+ ]);
31858
+ i18nInstance.addResources(locale, FORM_VIEWER_NAMESPACE, fieldTranslations);
31859
+ i18nInstance.addResources(locale, FORM_VIEWER_NAMESPACE, localeDataset3);
31855
31860
  return i18nInstance;
31856
31861
  }
31857
31862
  var FormProvider = ({