Skip to content

feat(translation): automatically translate user-generated content to the selected display language, if not spoken by the user #348

@nicobao

Description

@nicobao

Mainly requested by Search For Common Ground and ConnexUs, as they handle cross-languages consultations, but we expect this to be a must-have for everyone.

  • use a cloud translation API to:
    • detect the user-generated content's main language (conversations, opinions)
    • translate the content
  • store translations in the DB, next to the their content (create new language-specific columns)
  • when the user-generated content is first created, also create the corresponding translations, but do it asynchronously (non-blocking, no transactions as well)
  • when a user visits the relevant page, if the translation exists, retrieve them, else, calculate them, store them, and retrieve them. This avoids unnecessary API calls as content is only translated once, and minimize waiting time. Most of the time the content should already be there, since it's done during user-content creation, but there can be time when the content hasn't been translated yet as these translations aren't done in a transaction together with adding the comment

UI aspect:

  • auto-translation is on by default in the settings, like on Reddit: all other users-generated content will be auto-translated into the user's display language, which make sense for our use-case
  • users can turn this off in the settings, which means they'll always see the original, and they will have to click on "Translate" to see the translated content.
  • in the frontend, always show the translated content based on display language directly IF AND ONLY IF the language of the content is not written in one of the "spoken" language of the user. Otherwise show the original with "Translate" button below the text
  • in the frontend, when something has been translated, show "Translated from Korean" for example with Korean the language it was originally written in
  • on click on "Translated from Korean", it would show the original content and the button would change to "Translate". Colours of the content & button would change depending on whether it is showing the original or the translated content, and depending on settings. If the auto-translation setting is turned on, the translated text would appear in the regular app colour, while the original text would appear in a distinct colour. It is the opposite when the auto-translation setting is turned off.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions