nyaruka / temba-components

General web components for site building
Other
4 stars 7 forks source link

Add multiple language localizations to compose component #283

Open susanm74 opened 1 year ago

susanm74 commented 1 year ago

potentially relevant broadcast discussions:

susanm74 commented 1 year ago

@ericnewcomer @rowanseymour

ericnewcomer commented 1 year ago

Hey @rowanseymour, @susanm74 is hitting on the oft discussed localized attachment question. I think I know where we landed on this, but I don't want to add confusion if I have it wrong. I'll let you chime in here first.

susanm74 commented 1 year ago

@ericnewcomer @rowanseymour just wanted to resolve how we want to handle partially localized attachments (see above) and let me know what attachments translations we should expect to save in this scenario

rowanseymour commented 1 year ago

We want the behaviour to be consistent between sending a broadcast from the UI and sending a broadcast in a flow. Currently this means we resolve each part of message separately - i.e. resolve the text by checking contact language, default org language, flow base language, then resolve the attachments that way, then quick replies.

So for example if we have a flow base language of eng, then the following translations on a broadcast:

{"eng": {"text": "hi"}, "spa": {"quick_replies": ["si", "no"], "ara": {"attachments": ["http://test.jpg"]}}}

will be resolved for contacts with these languages as follows:

"eng" => {"text": "hi", "attachments": [], "quick_replies": []}, 
"spa" => {"text": "hi", "attachments": [], "quick_replies": ["si", "no"]}}
"ara" => {"text": "hi", "attachments": ["http://test.jpg"], "quick_replies": []}}

That resolving currently happens in goflow/mailroom * and I think that's where it should stay. So the UI saves translations in their "sparse" format, and mailroom resolves what we actually send to a given contact.