R
Refine

ask-any-question

How to translate resource name?

Vvicious-gold5/27/2023
Hi, I'm trying to translate the error message caused by deletion of a resource. However the resource name in the message is not translated. Is there any way to translate it in common.json? (location-type is the resource name)
No description
Kkapa.ai5/27/2023
Hi @_erichu. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Kkapa.ai5/27/2023
---------------------- Yes, you can customize the error message by modifying the common.json file in your translation files. However, to translate the resource name, you'll need to use a function for the errorNotification prop in the useForm or useList hooks, depending on your use case. Here's an example of how to customize the error notification in the useForm hook:
useForm({
action: "create",
resource: "post",
errorNotification: (data, values, resource) => {
return {
message: `Something went wrong when deleting ${data.id}`,
description: "Error",
type: "error",
};
},
});
useForm({
action: "create",
resource: "post",
errorNotification: (data, values, resource) => {
return {
message: `Something went wrong when deleting ${data.id}`,
description: "Error",
type: "error",
};
},
});
Replace the message property with your translated resource name and error message. You can do the same for the useList hook if needed. For more information, refer to the following sources: - useForm errorNotification (https://refine.dev/docs/api-reference/core/hooks/useForm#errornotification) - useList errorNotification (https://refine.dev/docs/api-reference/core/hooks/data/useList#errornotification) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
useList | refine
useList is an extended version of TanStack Query's useQuery. It supports all the features of useQuery and adds some extra features.
useForm | refine
useForm is a hook that allows to manage forms. It has some action methods that create, edit and clone the form. The hook return value comes to according to the called action and it can run different logic depending on the action.
Kkapa.ai5/27/2023
<@454649036289343500> kapa.ai is still learning and improving, please let us how it did by reacting below

Looking for more? Join the community!

R
Refine

ask-any-question

Join Server