PHP 8.2.30
Preview: use-translation.js Size: 1.34 KB
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/adminjs/lib/frontend/hooks/use-translation.js

import { useTranslation as originalUseTranslation } from 'react-i18next';
import { createFunctions } from '../../utils/translate-functions.factory.js';

/**
 * Extends {@link TranslateFunctions}. Apart from that it also returns all the properties
 * defined below.
 *
 * ```javascript
 * import { useTranslation } from 'adminjs'
 *
 * const MyComponent = () => {
 *   const { translateButton } = useTranslation()
 *
 *   return (
 *     <Box>
 *       <Button variant="contained" onClick={...}>{translateButton('save')}<Button>
 *     </Box>
 *   )
 * }
 * ```
 *
 * @memberof useTranslation
 * @alias UseTranslationResponse
 *
 * @property {TranslateFunction} ... All functions defined in {@link TranslateFunctions}
 */

/**
 * @classdesc
 * Extends the useTranslation hook from react-i18next library.
 *
 * Returns all the {@link TranslateFunctions} + methods returned by the original
 * useTranslation method from react-i18next like: `i18n` instance and `ready` flag.
 *
 * @class
 * @subcategory Hooks
 * @bundle
 * @hideconstructor
 * @returns {UseTranslationResponse}
 */
export const useTranslation = () => {
  // eslint-disable-next-line no-shadow
  const {
    i18n,
    ...rest
  } = originalUseTranslation();
  const translateFunctions = createFunctions(i18n);
  return {
    ...rest,
    i18n,
    ...translateFunctions
  };
};
export default useTranslation;

Directory Contents

Dirs: 6 × Files: 10

Name Size Perms Modified Actions
- drwxr-xr-x 2026-02-28 00:31:56
Edit Download
- drwxr-xr-x 2026-02-28 00:31:56
Edit Download
- drwxr-xr-x 2026-02-28 00:31:56
Edit Download
- drwxr-xr-x 2026-02-28 00:31:56
Edit Download
- drwxr-xr-x 2026-02-28 00:31:56
Edit Download
- drwxr-xr-x 2026-02-28 00:31:58
Edit Download
563 B lrw-r--r-- 2026-02-28 00:31:44
Edit Download
1.19 KB lrw-r--r-- 2026-02-28 00:31:52
Edit Download
900 B lrw-r--r-- 2026-02-28 00:31:52
Edit Download
1.02 KB lrw-r--r-- 2026-02-28 00:31:52
Edit Download
3.07 KB lrw-r--r-- 2026-02-28 00:31:56
Edit Download
2.19 KB lrw-r--r-- 2026-02-28 00:31:52
Edit Download
2.16 KB lrw-r--r-- 2026-02-28 00:31:52
Edit Download
709 B lrw-r--r-- 2026-02-28 00:31:52
Edit Download
2.20 KB lrw-r--r-- 2026-02-28 00:31:52
Edit Download
1.34 KB lrw-r--r-- 2026-02-28 00:31:52
Edit Download

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