import { useCallback } from 'react';
import useEngineContext from "../../../../hooks/useEngineContext";
export var useTranslation = function useTranslation() {
  var context = useEngineContext();
  // 用 useCallback 稳定引用：避免作为详情拉取 effect / openByItem 的依赖时，
  // 父组件每次重渲染都触发重复的 GET /tenant/device/{id}
  return useCallback(function (val) {
    var _context$appHelper;
    var translation = context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.utils) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.translation;
    if (translation) return translation(val);
    if (!val) return '';
    if (typeof val === 'string') return val;
    return val.original || val.en || val['zh-CN'] || '';
  }, [context]);
};