From 1a37fa64f521629195626fd607cfd283bb2e2f82 Mon Sep 17 00:00:00 2001 From: Quentin Le Caignec <12102823+QuentinLeCaignec@users.noreply.github.com> Date: Wed, 31 Aug 2022 18:11:56 +0200 Subject: [PATCH 1/2] Update admin-customization.md for plugin translation Add instructions to admin-customization.md for extending a plugin's translations, which requires prefixing the key/value pair (declared in the plugin's translation file) with the plugin's name, for example `"content-type-builder.plugin.name": "Constructeur de Type-Contenu"` in order to translate the `plugin.name` key declared in `content-type-builder` plugin. This wasn't made clear by the documentation previously, since even for default plugins (such as content-type-builder) some fields are not translatable with the default method because they are declared independently in the plugin's files. I couldn't find any reference in the docs to the fact the plugin's name needed to be added as a prefix in order to extend a plugin's key. --- .../latest/development/admin-customization.md | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/docs/developer-docs/latest/development/admin-customization.md b/docs/developer-docs/latest/development/admin-customization.md index 1135a76ab2..0b30173521 100644 --- a/docs/developer-docs/latest/development/admin-customization.md +++ b/docs/developer-docs/latest/development/admin-customization.md @@ -388,6 +388,56 @@ export default { +To extend a plugin's key/value pair (which are declared independently in the plugin's files at `./admin/src/translations/[language-name].json`), you can similarly extend these in the `config.translations` key by prefixing the key with the plugin's name `[plugin name].[key]: 'value'` : + + + + +```js +// path: ./my-app/src/admin/app.js + +export default { + config: { + locales: ['fr'], + translations: { + fr: { + 'Auth.form.email.label': 'test', + // Translate a plugin's key/value pair by adding the plugin's name as a prefix + // In this case, we translate the "plugin.name" key of plugin "content-type-builder" + "content-type-builder.plugin.name": "Constructeur de Type-Contenu", + }, + }, + }, + bootstrap() {}, +}; +``` + + + + + + +```js +// path: ./my-app/src/admin/app.ts + +export default { + config: { + locales: ['fr'], + translations: { + fr: { + 'Auth.form.email.label': 'test', + // Translate a plugin's key/value pair by adding the plugin's name as a prefix + // In this case, we translate the "plugin.name" key of plugin "content-type-builder" + "content-type-builder.plugin.name": "Constructeur de Type-Contenu", + }, + }, + }, + bootstrap() {}, +}; +``` + + + If more translations files should be added, place them in `./src/admin/extensions/translations` folder. From 92c847e995850adacaf54207291e3497abccc40a Mon Sep 17 00:00:00 2001 From: Quentin Le Caignec <12102823+QuentinLeCaignec@users.noreply.github.com> Date: Fri, 23 Sep 2022 13:22:55 +0200 Subject: [PATCH 2/2] Update docs/developer-docs/latest/development/admin-customization.md Co-authored-by: Pierre Wizla --- docs/developer-docs/latest/development/admin-customization.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developer-docs/latest/development/admin-customization.md b/docs/developer-docs/latest/development/admin-customization.md index 0b30173521..e89c7ff826 100644 --- a/docs/developer-docs/latest/development/admin-customization.md +++ b/docs/developer-docs/latest/development/admin-customization.md @@ -388,7 +388,7 @@ export default { -To extend a plugin's key/value pair (which are declared independently in the plugin's files at `./admin/src/translations/[language-name].json`), you can similarly extend these in the `config.translations` key by prefixing the key with the plugin's name `[plugin name].[key]: 'value'` : +A plugin's key/value pairs are declared independently in the plugin's files at `./admin/src/translations/[language-name].json`. These key/value pairs can similarly be extended in the `config.translations` key by prefixing the key with the plugin's name (i.e. `[plugin name].[key]: 'value'`) as in the following example: