All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.initializers.i18n.js.map Maven / Gradle / Ivy

Go to download

A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.

There is a newer version: 4.12.3
Show newest version
{"version":3,"file":"i18n.js","names":["i18n","LanguageDetector","mergeDeepLeft","initReactI18next","LIST_FORMATS","listFormatter","lowerCaseDynamicTextFormatter","sentenceCaseProcessor","replaceNullValuesWithGetter","commonsEn","taxonomies","initializeI18n","hostTranslations","_window$globalProps","packageTranslations","preval","require","commonsTranslations","en","translation","resources","reduce","defaultTaxonomyKeys","Object","keys","taxonomyDefaultLabels","defaultTaxonomies","fromEntries","map","key","singular","plural","hostTaxonomies","window","globalProps","use","init","fallbackLng","interpolation","defaultVariables","escapeValue","skipOnVariables","alwaysFormat","format","value","lng","options","newValue","includes","postProcess","name","detection","order","caches","lookupQuerystring","lookupCookie"],"sources":["../../src/initializers/i18n.js"],"sourcesContent":["import i18n from \"i18next\";\nimport LanguageDetector from \"i18next-browser-languagedetector\";\nimport { mergeDeepLeft } from \"ramda\";\nimport { initReactI18next } from \"react-i18next\";\n\nimport { LIST_FORMATS } from \"./constants\";\nimport {\n  listFormatter,\n  lowerCaseDynamicTextFormatter,\n} from \"./utils/customFormatters\";\nimport { sentenceCaseProcessor } from \"./utils/customPostProcessors\";\nimport { replaceNullValuesWithGetter } from \"./utils/utils\";\n\nimport commonsEn from \"../translations/en.json\";\n\n// eslint-disable-next-line import/no-mutable-exports\nlet taxonomies = {};\n\nconst initializeI18n = hostTranslations => {\n  // eslint-disable-next-line no-undef\n  const packageTranslations = preval.require(\n    \"../configs/scripts/getPkgTranslations.js\"\n  );\n\n  const commonsTranslations = { en: { translation: commonsEn } };\n\n  const resources = [\n    hostTranslations,\n    commonsTranslations,\n    packageTranslations,\n  ].reduce(mergeDeepLeft);\n\n  const defaultTaxonomyKeys = Object.keys(\n    resources.en.translation.taxonomyDefaultLabels || {}\n  );\n\n  const defaultTaxonomies = Object.fromEntries(\n    defaultTaxonomyKeys.map(key => [key, { singular: null, plural: null }])\n  );\n\n  const hostTaxonomies = window.globalProps?.taxonomies || {};\n\n  taxonomies = replaceNullValuesWithGetter(\n    mergeDeepLeft(hostTaxonomies, defaultTaxonomies)\n  );\n\n  i18n\n    .use(LanguageDetector)\n    .use(initReactI18next)\n    .use(sentenceCaseProcessor)\n    .init({\n      resources,\n      fallbackLng: \"en\",\n      interpolation: {\n        defaultVariables: { taxonomies },\n        escapeValue: false,\n        skipOnVariables: false,\n        alwaysFormat: true,\n        format: (value, format, lng, options) => {\n          let newValue = value;\n\n          if (LIST_FORMATS.includes(format)) {\n            newValue = listFormatter({ value: newValue, format, lng, options });\n\n            return newValue;\n          }\n\n          return lowerCaseDynamicTextFormatter(newValue, format);\n        },\n      },\n      postProcess: [sentenceCaseProcessor.name],\n      detection: {\n        order: [\"querystring\", \"cookie\", \"navigator\", \"path\"],\n        caches: [\"cookie\"],\n        lookupQuerystring: \"lang\",\n        lookupCookie: \"lang\",\n      },\n    });\n};\n\nexport { taxonomies };\n\nexport default initializeI18n;\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,SAAS;AAC1B,OAAOC,gBAAgB,MAAM,kCAAkC;AAC/D,SAASC,aAAa,QAAQ,OAAO;AACrC,SAASC,gBAAgB,QAAQ,eAAe;AAEhD,SAASC,YAAY;AACrB,SACEC,aAAa,EACbC,6BAA6B;AAE/B,SAASC,qBAAqB;AAC9B,SAASC,2BAA2B;AAEpC,OAAOC,SAAS;;AAEhB;AACA,IAAIC,UAAU,GAAG,CAAC,CAAC;AAEnB,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAGC,gBAAgB,EAAI;EAAA,IAAAC,mBAAA;EACzC;EACA,IAAMC,mBAAmB,GAAGC,MAAM,CAACC,OAAO,CACxC,0CACF,CAAC;EAED,IAAMC,mBAAmB,GAAG;IAAEC,EAAE,EAAE;MAAEC,WAAW,EAAEV;IAAU;EAAE,CAAC;EAE9D,IAAMW,SAAS,GAA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