# Multi-language chat, announcements, etc

**URL:** <https://forum.adalo.com/t/multi-language-chat-announcements-etc/10240>\
**Category:** Get Help\
**Created:** [March 12, 2021, 2:06pm UTC](https://forum.adalo.com/t/multi-language-chat-announcements-etc/10240 "2021-03-12T14:06:59Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Repackaged](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/repackaged/32/6573_2.png) [@Repackaged](https://forum.adalo.com/u/Repackaged)\
**Post date:** [March 15, 2021, 8:19pm UTC](https://forum.adalo.com/t/multi-language-chat-announcements-etc/10240/5 "2021-03-15T20:19:59Z")

</div>

You bet.  
Here’s what I did for an app I have in which I have stories I automatically translate to several languages.

1- Database structure.  
This is the view of a story.

- The body field captures the text of the current story
- The language field captures the language of the current story (more on that later)
- Then I have many localized fields to capture translations for Indonesian (id), French (fr), Arabic (ar), English (en) … and others  
 ![Screen Shot 2021-03-15 at 3.40.57 PM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/0/0365f7b281e693e3653bc47836f107b194e66515.png)

2- When a story is created:  
As users create new stories, I run several actions as soon as users hit the create a story button.

 ![Screen Shot 2021-03-15 at 3.50.06 PM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/4/4bfaa38d243fb7c96075dd6e9c3069e22179309a.png)

- 2.a Unmask a Lottie Spinner
- 2.b Detect the language of the current story (API call to Google Translate’s Natural Language detection) - More information below
- 2.c Now that we know which language the story is, we run several translations (IN, FR, EN, AR, …) - More information below
- 2.d Create a new story feeding all fields - More below
- 2.e Send notifications to the current user’s followers
- 2.f Mask the Lottie Spinner

More info regarding 2.b (language detection)

 ![Screen Shot 2021-03-15 at 3.59.28 PM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/5/5715ae496fcf07f97f09bb0b939a4abd7a8580f9.png)  
This API call takes the current story input as an input to the call.

This is how I set up the API call:

 ![Screen Shot 2021-03-15 at 4.00.57 PM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/6/6459fa669279adc05aa19a1264d1fa493099b4e7.png)

This is where I pass the story input to the API

 ![Screen Shot 2021-03-15 at 4.01.20 PM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/c/c019a768fb4fea904807ebc95d6b87b452224c52.png)

Note that the API Key is added to the URL endpoint - You can get yours as you create your Google Platform account and ask for a Google Translate API key.

 ![Screen Shot 2021-03-15 at 4.05.13 PM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/8/84b764f6a394ec0270d42c92fbf3ba8d98842c1b.png)

The API will send back the detected language of the story.

Let’s move to 2.c  
This is where you call the Google Translate API for each of your target languages.

 ![Screen Shot 2021-03-15 at 4.07.44 PM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/9/9231a969b01b4de60df11d786fb3aab853d4f12e.png)

Note that the API call take 3 fields. The text to translate, the source language (which is the result of the previous call - Thanks Adalo for making that result available), and the target language (fr for French in this case).

Here’s the structure of the API call:

 ![Screen Shot 2021-03-15 at 4.10.04 PM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/a/a409af2dcf1f2e6c9052601600ecaf67bf32170d.png)

 ![Screen Shot 2021-03-15 at 4.10.31 PM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/d/d662dceb8dd274fc3ad883ba40ac9be132e32958.png)  
The API call requires these 3 fields at a minimum to be able to work.

 ![Screen Shot 2021-03-15 at 4.11.04 PM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/7/72b4a63aea3d1fe0f65ac4df797c71f022e46740.png)  
The API call send back the translation field which you can use to store in the DB

Last stop, 2.d.  
You can run the Google Translate API call as many times you have target languages. You only need to change the target language to the google code of that language.

Now that you have everything done, all you have to do is create a Story object in the DB (in my case) i which you store all of your data.

 ![Screen Shot 2021-03-15 at 4.17.00 PM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/a/ad0aec4ac13c5cccbf8a512e1fde8ec591edb4c7.png)  
 ![Screen Shot 2021-03-15 at 4.17.14 PM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/8/8b01e6f83e41247773f2a1104cd23cb17ccf865a.png)

There are some tips along the way that I haven’t described yet but I hope at least this will get you going and excited.

I also want to point out that I do the same thing when users:

- edit existing stories
- create comments (seme structure)
- edit existing comments

Let me know  
Best and keep building.

---

_[View the full topic](https://forum.adalo.com/t/multi-language-chat-announcements-etc/10240)._
