You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Strapi集成DeepL自动翻译插件失效问题求助

Strapi DeepL自动翻译故障排查方案

1. 修正API请求地址错误

当前请求指向localhost:1337/translate/translate是异常的,需确保插件配置中指定了正确的DeepL API端点:

  • 免费版DeepL API地址:https://api-free.deepl.com/v2/translate
  • 付费版DeepL API地址:https://api.deepl.com/v2/translate

在config/plugins.js的translate配置中,明确设置apiEndpoint参数,同时确保从环境变量正确读取API密钥:

module.exports = ({ env }) => ({
  translate: {
    enabled: true,
    config: {
      provider: 'deepl',
      providerOptions: {
        apiKey: env('DEEPL_API_KEY'),
        apiEndpoint: env('DEEPL_API_ENDPOINT', 'https://api-free.deepl.com/v2/translate'),
      },
      // 其他配置...
    },
  },
});

2. 验证插件与Strapi版本兼容性

确认strapi-plugin-translate和strapi-provider-translate-deepl的版本与当前Strapi主版本(如v4)匹配,卸载不兼容版本后重装对应适配版本:

npm uninstall strapi-plugin-translate strapi-provider-translate-deepl
npm install strapi-plugin-translate@适配版本 strapi-provider-translate-deepl@适配版本

3. 字段本地化配置二次核查

  • 目标集合类型必须已开启本地化功能
  • 需要翻译的字段需勾选「Localized」选项
  • 在translate插件配置的contentTypes数组中,准确填写集合UID、源/目标语言列表、待翻译字段名称:
contentTypes: [
  {
    uid: 'api::article.article',
    locales: ['zh-CN', 'en'], // 第一位为源语言,后续为目标语言
    fields: ['title', 'content'],
  },
],

4. 直接测试DeepL API有效性

用curl命令验证API密钥和端点是否正常工作,替换YOUR_API_KEY为实际密钥:

curl -X POST "https://api-free.deepl.com/v2/translate" \
  -H "Authorization: DeepL-Auth-Key YOUR_API_KEY" \
  -d "text=测试文本" \
  -d "target_lang=EN"

若返回正常翻译结果,说明密钥和端点无问题;若报错,检查密钥是否为免费版专用、是否存在拼写错误。

5. 清除缓存并重启服务

修改配置后需清除Strapi缓存并重启,确保配置生效:

rm -rf .cache build
npm run develop

6. 弃用过时插件

strapi-plugin-deepl已停止维护,无需继续排查该插件的错误,专注使用官方推荐的strapi-plugin-translate + strapi-provider-translate-deepl组合即可。

内容的提问来源于stack exchange,提问作者Kvasir

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 15:10:03