PHP 8.2.30
Preview: withTranslation.js Size: 3.09 KB
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/react-i18next/dist/commonjs/withTranslation.js

"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.withTranslation = withTranslation;

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _react = require("react");

var _useTranslation3 = require("./useTranslation.js");

var _utils = require("./utils.js");

var _excluded = ["forwardedRef"];

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) { (0, _defineProperty2["default"])(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; }

function withTranslation(ns) {
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  return function Extend(WrappedComponent) {
    function I18nextWithTranslation(_ref) {
      var forwardedRef = _ref.forwardedRef,
          rest = (0, _objectWithoutProperties2["default"])(_ref, _excluded);

      var _useTranslation = (0, _useTranslation3.useTranslation)(ns, _objectSpread(_objectSpread({}, rest), {}, {
        keyPrefix: options.keyPrefix
      })),
          _useTranslation2 = (0, _slicedToArray2["default"])(_useTranslation, 3),
          t = _useTranslation2[0],
          i18n = _useTranslation2[1],
          ready = _useTranslation2[2];

      var passDownProps = _objectSpread(_objectSpread({}, rest), {}, {
        t: t,
        i18n: i18n,
        tReady: ready
      });

      if (options.withRef && forwardedRef) {
        passDownProps.ref = forwardedRef;
      } else if (!options.withRef && forwardedRef) {
        passDownProps.forwardedRef = forwardedRef;
      }

      return (0, _react.createElement)(WrappedComponent, passDownProps);
    }

    I18nextWithTranslation.displayName = "withI18nextTranslation(".concat((0, _utils.getDisplayName)(WrappedComponent), ")");
    I18nextWithTranslation.WrappedComponent = WrappedComponent;

    var forwardRef = function forwardRef(props, ref) {
      return (0, _react.createElement)(I18nextWithTranslation, Object.assign({}, props, {
        forwardedRef: ref
      }));
    };

    return options.withRef ? (0, _react.forwardRef)(forwardRef) : I18nextWithTranslation;
  };
}

Directory Contents

Dirs: 0 × Files: 15

Name Size Perms Modified Actions
4.00 KB lrw-r--r-- 2026-02-28 00:26:50
Edit Download
1.76 KB lrw-r--r-- 2026-02-28 00:27:26
Edit Download
560 B lrw-r--r-- 2026-02-28 00:27:48
Edit Download
257 B lrw-r--r-- 2026-02-28 00:28:06
Edit Download
3.37 KB lrw-r--r-- 2026-02-28 00:28:24
Edit Download
438 B lrw-r--r-- 2026-02-28 00:28:28
Edit Download
2.98 KB lrw-r--r-- 2026-02-28 00:28:48
Edit Download
1000 B lrw-r--r-- 2026-02-28 00:28:52
Edit Download
12.65 KB lrw-r--r-- 2026-02-28 00:28:58
Edit Download
814 B lrw-r--r-- 2026-02-28 00:29:00
Edit Download
1.13 KB lrw-r--r-- 2026-02-28 00:29:02
Edit Download
5.92 KB lrw-r--r-- 2026-02-28 00:29:06
Edit Download
3.64 KB lrw-r--r-- 2026-02-28 00:29:08
Edit Download
2.19 KB lrw-r--r-- 2026-02-28 00:29:10
Edit Download
3.09 KB lrw-r--r-- 2026-02-28 00:29:12
Edit Download

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