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

package.cjs.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":["_i18next","_interopRequireDefault","require","_i18nextBrowserLanguagedetector","_ramda","_reactI18next","_constants","_customFormatters","_customPostProcessors","_utils","_en","taxonomies","exports","initializeI18n","hostTranslations","_window$globalProps","packageTranslations","preval","commonsTranslations","en","translation","commonsEn","resources","reduce","mergeDeepLeft","defaultTaxonomyKeys","Object","keys","taxonomyDefaultLabels","defaultTaxonomies","fromEntries","map","key","singular","plural","hostTaxonomies","window","globalProps","replaceNullValuesWithGetter","i18n","use","LanguageDetector","initReactI18next","sentenceCaseProcessor","init","fallbackLng","interpolation","defaultVariables","escapeValue","skipOnVariables","alwaysFormat","format","value","lng","options","newValue","LIST_FORMATS","includes","listFormatter","lowerCaseDynamicTextFormatter","postProcess","name","detection","order","caches","lookupQuerystring","lookupCookie","_default"],"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,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,+BAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AAIA,IAAAM,qBAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAEA,IAAAQ,GAAA,GAAAT,sBAAA,CAAAC,OAAA;AAEA;AACA,IAAIS,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,CAAC,CAAC;AAEnB,IAAME,cAAc,GAAG,SAAjBA,cAAcA,CAAGC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