File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,48 @@ If you don't follow the rule and decide to store some of your translatable conte
9898
9999So, 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
You can’t perform that action at this time.
0 commit comments