Add support for e-mail translations

Created on 18 August 2023, over 1 year ago
Updated 29 August 2023, over 1 year ago

Problem/Motivation

For a multilanguage site, we'd like to have:
- one calendar where we can translate its title, description (these can be done right now at /admin/config/regional/content-language) and overridden e-mail texts (these need to be marked translatable)
- multiple available datetimes.
- depending on the user who submits a booking, we'd like to send e-mail in language based on user preference or in case of anonymous visitors, the currently used language. Right now, these are not translatable.
- plus, if it is not a big request: since we're using tokens in e-mail texts, we should add the usual "Browse for available tokens" link if the token module is installed. Just as the webform and countless of other modules do.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

โœจ Feature request
Status

Fixed

Version

2.2

Component

Code

Created by

๐Ÿ‡ธ๐Ÿ‡ฐSlovakia kaszarobert

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

Comments & Activities

  • Issue created by @kaszarobert
  • @kaszarobert opened merge request.
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ธ๐Ÿ‡ฐSlovakia kaszarobert

    I added a few things:
    - I added the missing schema for the settings, that made the form to be translatable
    - In the BookableCalendar entity, I set notification_email_subject, notification_email_body, notification_email_subject_cancel, notification_email_body_cancel to be translatable
    - Also, I added the "Browse for available tokens" to both forms
    - In Notification class, we detect the language to use in mail that way: if it is a valid user, use its preferred langcode. If anonymous, use the current site language. Also, I'm passing a bookable_calendar object to the token because if someone's enabled translation for the Calendar fields, we need to use the proper translation.
    - also for a few tokens that may load referenced translatable entity, I added to code to use the exact language we need (if that does exist for that entity). Otherwise they loaded the original language only.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States josh.fabean

    josh.fabean โ†’ made their first commit to this issueโ€™s fork.

  • Status changed to Fixed over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States josh.fabean

    Tested that and everything seems to work as desired. Only change I made was change function _load_translated_entity to be namespaced to the module to not cause issues with other modules possibly.

    In latest dev, will be in version 2.2.9 which should release today or tomorrow.

  • Status changed to Fixed over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States josh.fabean
Production build 0.71.5 2024