How to write a multilingual embeded app with React ?

Solved
Highlighted
Tourist
15 0 1

Hi,

 

How to set multilingual text using React ?

 

For example:

<Page
    fullWidth
    title="My title"
/>

Is the above component, how to adapt "title" to shop admin locale ?

 

Thanks,

 

0 Likes
Highlighted
Shopify Partner
117 25 30

This is an accepted solution.

Hi boolangery,

 

You can start by having all your text in a file.

 

In your component you need to import that file and select the language based on props or state, depending how you go about it.

 

Here is a example:

 

languages.js:

const translations = {
  english: {
    title: "My site",
},
spanish: {
   title: "Mi título",
},
};

export default translations;

And your component:

import languages from "./languages";

<Page
    fullWidth
    title={languages.english.title}
/>

 

- Yes, we build Shopify Apps. Hit me with your idea: https://vellir.tech
- Let customers preview your products and easily add them to cart with Peek Mode
- Add free, good looking social share icons with built-in analytics to your store with Share Lab
- Manage your new arrivals with Newr
0 Likes