PHP 8.2.30
Preview: context.js Size: 2.90 KB
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/react-i18next/dist/es/context.js

import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

import { createContext } from 'react';
import { getDefaults, setDefaults } from './defaults.js';
import { getI18n, setI18n } from './i18nInstance.js';
import { initReactI18next } from './initReactI18next.js';
export { getDefaults, setDefaults, getI18n, setI18n, initReactI18next };
export var I18nContext = createContext();
export var ReportNamespaces = function () {
  function ReportNamespaces() {
    _classCallCheck(this, ReportNamespaces);

    this.usedNamespaces = {};
  }

  _createClass(ReportNamespaces, [{
    key: "addUsedNamespaces",
    value: function addUsedNamespaces(namespaces) {
      var _this = this;

      namespaces.forEach(function (ns) {
        if (!_this.usedNamespaces[ns]) _this.usedNamespaces[ns] = true;
      });
    }
  }, {
    key: "getUsedNamespaces",
    value: function getUsedNamespaces() {
      return Object.keys(this.usedNamespaces);
    }
  }]);

  return ReportNamespaces;
}();
export function composeInitialProps(ForComponent) {
  return function (ctx) {
    return new Promise(function (resolve) {
      var i18nInitialProps = getInitialProps();

      if (ForComponent.getInitialProps) {
        ForComponent.getInitialProps(ctx).then(function (componentsInitialProps) {
          resolve(_objectSpread(_objectSpread({}, componentsInitialProps), i18nInitialProps));
        });
      } else {
        resolve(i18nInitialProps);
      }
    });
  };
}
export function getInitialProps() {
  var i18n = getI18n();
  var namespaces = i18n.reportNamespaces ? i18n.reportNamespaces.getUsedNamespaces() : [];
  var ret = {};
  var initialI18nStore = {};
  i18n.languages.forEach(function (l) {
    initialI18nStore[l] = {};
    namespaces.forEach(function (ns) {
      initialI18nStore[l][ns] = i18n.getResourceBundle(l, ns) || {};
    });
  });
  ret.initialI18nStore = initialI18nStore;
  ret.initialLanguage = i18n.language;
  return ret;
}

Directory Contents

Dirs: 0 × Files: 16

Name Size Perms Modified Actions
2.90 KB lrw-r--r-- 2026-02-28 00:27:06
Edit Download
1.48 KB lrw-r--r-- 2026-02-28 00:27:34
Edit Download
429 B lrw-r--r-- 2026-02-28 00:27:58
Edit Download
135 B lrw-r--r-- 2026-02-28 00:28:10
Edit Download
994 B lrw-r--r-- 2026-02-28 00:28:26
Edit Download
246 B lrw-r--r-- 2026-02-28 00:28:30
Edit Download
37 B lrw-r--r-- 2026-02-28 00:29:16
Edit Download
2.58 KB lrw-r--r-- 2026-02-28 00:28:50
Edit Download
687 B lrw-r--r-- 2026-02-28 00:28:54
Edit Download
11.97 KB lrw-r--r-- 2026-02-28 00:28:58
Edit Download
684 B lrw-r--r-- 2026-02-28 00:29:00
Edit Download
1.02 KB lrw-r--r-- 2026-02-28 00:29:04
Edit Download
5.49 KB lrw-r--r-- 2026-02-28 00:29:06
Edit Download
3.38 KB lrw-r--r-- 2026-02-28 00:29:10
Edit Download
1.89 KB lrw-r--r-- 2026-02-28 00:29:10
Edit Download
2.73 KB lrw-r--r-- 2026-02-28 00:29:12
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).