v4 代码迁移:更新翻译
¥v4 code migration: Updating translations
本指南是 v4 代码迁移指南 的一部分,旨在帮助你将 Strapi 应用的代码从 v3.6.x 迁移到 v4.0.x
¥This guide is part of the v4 code migration guide designed to help you migrate the code of a Strapi application from v3.6.x to v4.0.x
在 Strapi v3 中,支持文件替换来自定义 Strapi 应用的前端。要修改应用的翻译,可以直接用自定义文件替换原始核心文件。
¥In Strapi v3, file replacement is supported to customize the frontend of a Strapi application. To modify the translations of an application, original core files can be directly replaced with custom files.
在 Strapi v4 中,不再支持文件替换。要扩展翻译,应使用 专用扩展 API。
¥In Strapi v4, file replacement is no longer supported. To extend translations, dedicated extension APIs should be used.
要将翻译更新为 Strapi v4:
¥To update translations to Strapi v4:
将
./src/admin/app.example.js
重命名为./src/admin/app.js
。¥Rename the
./src/admin/app.example.js
to./src/admin/app.js
.在
config.locales
数组中,添加应用应支持的区域设置。¥In the
config.locales
array, add the locales the application should support.在
config.translations.<your-translation>
对象中,添加缺少的键。¥In the
config.translations.<your-translation>
object, add the missing keys.
Example: Adding translations to Strapi v4
export default {
config: {
// Add another locale
locales: ['fr'],
translations: {
// Add missing keys in the FR locale
fr: {
'Auth.form.email.label': 'test',
Users: 'Utilisateurs',
City: 'CITY (FRENCH)',
// Customize the label of the Content-Manager table.
Id: 'ID french',
},
},
},
bootstrap() {},
};