rising-crimson
rising-crimson7mo ago

How to customize/localize a resource's name?

Hi, is there any place where we can set a name of a resource, better with multiple language versions, in order to display the name when a resource is saved or deleted? In the image below I can't find where I can change the name of the resource in the message
No description
5 Replies
kapa.ai
kapa.ai7mo ago
Hi @Eric Hu. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Yes, you can customize the name of a resource using the meta property in the <Refine> component. The label property inside meta is used to set the name to show in the menu. By default, the plural form of the resource name is shown. Here is an example:
<Refine
resources={[
{
/* ... */
meta: { label: "custom" },
},
]}
/>
<Refine
resources={[
{
/* ... */
meta: { label: "custom" },
},
]}
/>
(Source: Refine Documentation (https://refine.dev/docs/core/refine-component#meta)) For localization or supporting multiple languages, Refine supports i18n. You can create your own translation files to override Refine's default texts. The translation keys that you can override are listed in the documentation. (Source: Refine Documentation (https://refine.dev/docs/guides-concepts/i18n#translation-file)) However, based on the provided extracts, there is no specific information on how to localize the resource name in the save or delete message. You may need to refer to the full documentation or the community for more specific guidance. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai7mo ago
<@454649036289343500> kapa.ai is still learning and improving, please let us know how it did by reacting below
rising-crimson
rising-crimson7mo ago
@kapa.ai So it's meta: {label: "custom"} instead of options: { label: "custom" } right?
kapa.ai
kapa.ai7mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Yes, that's correct. In the migration from version 3.x.x to 4.x.x of Refine, the options prop of a resource was deprecated and replaced with the meta prop. So you should use meta: { label: "custom" } to set a custom name for your resource. Here's how you can do it:
<Refine
resources={[
{
name: "posts",
meta: { label: "custom" },
},
]}
/>
<Refine
resources={[
{
name: "posts",
meta: { label: "custom" },
},
]}
/>
(Source: Refine Documentation (https://refine.dev/docs/migration-guide/3x-to-4x#resource-optionss-to-meta)) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai7mo ago
<@454649036289343500> kapa.ai is still learning and improving, please let us know how it did by reacting below