[Multilingual] Notifications are not translatable

Created on 21 November 2022, about 2 years ago
Updated 15 May 2023, over 1 year ago

Problem/Motivation

Notifications messages are not translatable. Messages are already generated as html before the language context is known.

Steps to reproduce

Install the module, create some notifications and try to change interface language.

Proposed resolution

Expose original notification message to be passed into t() function where it will be exposed to interface language translation.

Remaining tasks

Modify notification message item recording in "NotificationsWidgetService.php" to store is as plain text.

User interface changes

The language of notifications will change with the interface language.

API changes

NA

Data model changes

NA

Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Small update to avoid spurious warning on custom field 'date_unpub'.

  • Status changed to Needs work almost 2 years ago
  • 🇧🇪Belgium BramDriesen Belgium 🇧🇪

    Hi everyone. Thanks for working on this!

    I'm a bit lost between the patches. The patch in #3 looks more complete as #5& #6. Was this a mistake? Or am I missing something here?

  • 🇧🇪Belgium BramDriesen Belgium 🇧🇪

    2.x would be more appropriate.

  • Hi @BramDriesen,

    I did not manage to make the patch #3 work. Si I made my own, but it is a kind of mismatch between general use and specific.

    Previously the notification was created with some token and replaced before being stored into the database in the current context within the current language. So, the complete notification was published and readable in only one language (because with replaced tokens the rendered sentence is no more generic and not translatable).

    What I have done is keep these token unreplaced, so that the sentence stored into the database is a generic one and can be translated.
    And then during the final rendering of the notification I replace token with the correct words translated and the translated generic sentence.

    To do so I have created some attributes to be store in the database to feed token (user id, node id, publication date etc...) to get node title translated for ex.

    So these attributes are custom and depending on what we want to see in notification messages. The patch may not directly work on your environnement, but the mechanism to store le notification untokenized can be reused.

    Ideally a generic feature shall be implemented to store automatically required attributes for token used to create the notification.

  • Please find a patch updated for v1.8

Production build 0.71.5 2024