Skip to content

Commit 7db0a71

Browse files
committed
chore: upd readme
1 parent 2fea67c commit 7db0a71

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

readme.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,48 @@ If you don't follow the rule and decide to store some of your translatable conte
9898

9999
So, if you want a hassle-free i18n on autopilot, **follow The Replexica Rule** whenever possible.
100100

101+
### But what if I have an array of items, and some of the fields should be translated?
102+
103+
There's a common scenario, when you have an array of items that you render in a list, like this:
104+
105+
```jsx
106+
const menuItems = [
107+
{
108+
title: 'Home',
109+
url: '/',
110+
},
111+
{
112+
title: 'About',
113+
url: '/about',
114+
},
115+
{
116+
title: 'Contact',
117+
url: '/contact',
118+
},
119+
];
120+
```
121+
122+
In this case, you can still follow the Replexica Rule by simply wrapping the text in JSX! Here's how you can do it:
123+
124+
```jsx
125+
const menuItesm = [
126+
{
127+
title: <>Home</>,
128+
url: '/',
129+
},
130+
{
131+
title: <>About</>,
132+
url: '/about',
133+
},
134+
{
135+
title: <>Contact</>,
136+
url: '/contact',
137+
},
138+
];
139+
```
140+
141+
And that's it! The Replexica Compiler will automatically infer the metadata from the JSX and prepare the text for translation.
142+
101143
## Getting Started
102144

103145
### Step 1. Install Replexica

0 commit comments

Comments
 (0)