tame-yellow
tame-yellow2mo ago

Can refine i18n provider change the resource label?

Is it possible for me just to provide a key when defining a resource meta label and refine i18n provider knows to change the label based on the key and language etc?
2 Replies
kapa.ai
kapa.ai2mo ago
Hi @JuicyBenjamin. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Yes, refine's i18n provider can change the resource label, and you can indeed provide a key when defining a resource meta label for internationalization. Here's how you can achieve this: 1. When defining your resources, you can set the label in the meta object to a translation key instead of a static string:
export const App = () => (
<Refine
// ...
resources={[
{
name: "posts",
meta: {
label: "resources.posts.label",
},
},
]}
/>
);
export const App = () => (
<Refine
// ...
resources={[
{
name: "posts",
meta: {
label: "resources.posts.label",
},
},
]}
/>
);
2. In your translation files, you would then provide the corresponding translations for this key. For example, in your en/common.json:
{
"resources": {
"posts": {
"label": "Posts"
}
}
}
{
"resources": {
"posts": {
"label": "Posts"
}
}
}
And in your de/common.json:
{
"resources": {
"posts": {
"label": "Beiträge"
}
}
}
{
"resources": {
"posts": {
"label": "Beiträge"
}
}
}
3. Refine will automatically use the i18n provider to translate these labels based on the current language. This approach allows you to easily manage and change resource labels across different languages without modifying your component code. For more details on setting up and using i18n in refine, you can refer to the i18n Provider documentation (https://refine.dev/docs/core/providers/i18n-provider/) and the Internationalization guide (https://refine.dev/docs/guides-concepts/i18n/). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@167296048367140864> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?