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

import { createElement, forwardRef as forwardRefReact } from 'react';
import { useTranslation } from './useTranslation.js';
import { getDisplayName } from './utils.js';

export function withTranslation(ns, options = {}) {
  return function Extend(WrappedComponent) {
    function I18nextWithTranslation({ forwardedRef, ...rest }) {
      const [t, i18n, ready] = useTranslation(ns, { ...rest, keyPrefix: options.keyPrefix });

      const passDownProps = {
        ...rest,
        t,
        i18n,
        tReady: ready,
      };
      if (options.withRef && forwardedRef) {
        passDownProps.ref = forwardedRef;
      } else if (!options.withRef && forwardedRef) {
        passDownProps.forwardedRef = forwardedRef;
      }
      return createElement(WrappedComponent, passDownProps);
    }

    I18nextWithTranslation.displayName = `withI18nextTranslation(${getDisplayName(
      WrappedComponent,
    )})`;

    I18nextWithTranslation.WrappedComponent = WrappedComponent;

    const forwardRef = (props, ref) =>
      // eslint-disable-next-line prefer-object-spread
      createElement(I18nextWithTranslation, Object.assign({}, props, { forwardedRef: ref }));

    return options.withRef ? forwardRefReact(forwardRef) : I18nextWithTranslation;
  };
}

Directory Contents

Dirs: 0 × Files: 15

Name Size Perms Modified Actions
1.92 KB lrw-r--r-- 2026-02-28 00:27:18
Edit Download
655 B lrw-r--r-- 2026-02-28 00:27:42
Edit Download
358 B lrw-r--r-- 2026-02-28 00:28:02
Edit Download
138 B lrw-r--r-- 2026-02-28 00:28:14
Edit Download
892 B lrw-r--r-- 2026-02-28 00:28:28
Edit Download
237 B lrw-r--r-- 2026-02-28 00:28:30
Edit Download
1018 B lrw-r--r-- 2026-02-28 00:28:52
Edit Download
290 B lrw-r--r-- 2026-02-28 00:28:56
Edit Download
13.06 KB lrw-r--r-- 2026-02-28 00:28:58
Edit Download
663 B lrw-r--r-- 2026-02-28 00:29:00
Edit Download
1.22 KB lrw-r--r-- 2026-02-28 00:29:06
Edit Download
4.97 KB lrw-r--r-- 2026-02-28 00:29:08
Edit Download
4.10 KB lrw-r--r-- 2026-02-28 00:29:10
Edit Download
712 B lrw-r--r-- 2026-02-28 00:29:12
Edit Download
1.23 KB lrw-r--r-- 2026-02-28 00:29:14
Edit Download

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