By xuhuan
The interface is used to translate specified fields, primarily for the slug field, to facilitate the generation of frontend URLs.
released November 28, 2025
npm install enhanced-slugThe interface is used to translate specified fields, primarily for the slug field, to facilitate the generation of frontend URLs.
The suggestion is primarily intended for fields such as titles.
Aliyun's Professional Translation Edition offers specialized scenarios suitable for title translation, so the API call utilizes the Professional Edition. Both the Professional and General Editions share the same free quota under the same account.
Simply install the plugin
npm i enhanced-slugpnpm i enhanced-slugyarn add enhanced-slugThis is a component, choose custom component when adding it
<img src=https://raw.githubusercontent.com/xuhuan/enhanced-slug/refs/heads/main/doc/images/use-en.png width=800/>
Below is the input box effect and usage effect. When the content of the associated field changes, it will automatically trigger the generation. You can also manually click the button to trigger the generation, or modify the final slug component content yourself.
<img src=https://raw.githubusercontent.com/xuhuan/enhanced-slug/refs/heads/main/doc/images/use-en2.png width=800/>
<img src=https://raw.githubusercontent.com/xuhuan/enhanced-slug/refs/heads/main/doc/images/use-en3.png width=800/>
<img src=https://raw.githubusercontent.com/xuhuan/enhanced-slug/refs/heads/main/doc/images/setting-en.png width=800/> <img src=https://raw.githubusercontent.com/xuhuan/enhanced-slug/refs/heads/main/doc/images/setting-en2.png width=800/> <img src=https://raw.githubusercontent.com/xuhuan/enhanced-slug/refs/heads/main/doc/images/setting-en3.png width=800/>
Free quota: 5 million characters per month
Secret ID: Your Tencent Cloud Secret ID
Secret Key: Your Tencent Cloud Secret Key
Region: ap-beijing (or other region)
Project ID: 0 (default project)How to obtain:
Free quota: 1 million characters per month
App ID: Your Alibaba Cloud AccessKey ID
App Key: Your Alibaba Cloud AccessKey SecretNo configuration required, uses the free @vitalets/google-translate-api package.
Enabling the "Automatically Switch on Failure" option automatically generates a slug using Pinyin mode when all translation engines fail.
Translation engines are used in the order they are enabled in the settings page:
In the development environment, you can view detailed logs:
// server/src/services/slug.ts
strapi.log.debug('Translator response:', result);You can follow my WeChat official account for support.
<img src=https://raw.githubusercontent.com/xuhuan/enhanced-slug/refs/heads/main/doc/images/fifthtimezone.jpg width=200/>
You can also add me as your WeChat friend.
<img src=https://raw.githubusercontent.com/xuhuan/enhanced-slug/refs/heads/main/doc/images/wechat.png width=200/>
Yes, I work for a travel agency. If you'd like to book a tour with me, I wouldn't refuse.
MIT License
调用接口对指定字段进行翻译,主要用于slug字段,方便前端url地址的生成。
建议主要用于标题这类类型的字段。
阿里云翻译专业版有专门的场景适合标题翻译,所以阿里云接口调用的是专业版,专业版和通用版是共享账号的免费额度。
安装插件即可
npm i enhanced-slugpnpm i enhanced-slugyarn add enhanced-slug这个是组件,添加的时候选择自定义组件
<img src=https://raw.githubusercontent.com/xuhuan/enhanced-slug/refs/heads/main/doc/images/use-en.png width=800/>
下面是输入框效果和使用效果,关联字段内容变更后会自动触发生成,也可以手动点击按钮触发生成,或者自行修改最终的slug组件内容。
<img src=https://raw.githubusercontent.com/xuhuan/enhanced-slug/refs/heads/main/doc/images/use2.png width=800/>
<img src=https://raw.githubusercontent.com/xuhuan/enhanced-slug/refs/heads/main/doc/images/use3.png width=800/>
<img src=https://raw.githubusercontent.com/xuhuan/enhanced-slug/refs/heads/main/doc/images/setting.png width=800/> <img src=https://raw.githubusercontent.com/xuhuan/enhanced-slug/refs/heads/main/doc/images/setting2.png width=800/> <img src=https://raw.githubusercontent.com/xuhuan/enhanced-slug/refs/heads/main/doc/images/setting3.png width=800/>
免费额度每月500万字符
Secret ID: 你的腾讯云 Secret ID
Secret Key: 你的腾讯云 Secret Key
Region: ap-beijing (或其他地域)
Project ID: 0 (默认项目)获取方式:
免费额度每月100万字符
App ID: 你的阿里云 AccessKey ID
App Key: 你的阿里云 AccessKey Secret无需配置,使用免费的 @vitalets/google-translate-api 包。
启用"失败时自动切换"选项后,当所有翻译引擎都失败时,系统会自动使用拼音模式生成 slug。
翻译引擎的使用顺序按照在设置页面中启用的顺序:
翻译失败
中文转拼音不正确
TypeScript 错误
在开发环境中,可以查看详细日志:
// server/src/services/slug.ts
strapi.log.debug('Translator response:', result);可以关注我的微信公众号支持一下。
<img src=https://raw.githubusercontent.com/xuhuan/enhanced-slug/refs/heads/main/doc/images/fifthtimezone.jpg width=200/>
也可以加我的微信好友。
<img src=https://raw.githubusercontent.com/xuhuan/enhanced-slug/refs/heads/main/doc/images/wechat.png width=200/>
没错,作者是旅行社的,你们要是愿意找我报团我也是不会拒绝的~
MIT License
Share your work with the community and get it listed in the Strapi ecosystem for everyone to discover and use.
Submit
