Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use email feature in multi-language environment #50

Open
clarkwinkelmann opened this issue Apr 29, 2024 · 0 comments
Open

Cannot use email feature in multi-language environment #50

clarkwinkelmann opened this issue Apr 29, 2024 · 0 comments
Labels

Comments

@clarkwinkelmann
Copy link
Member

Bug Report

Current Behavior
After the first ever email is sent, the translation is saved to the settings. Changing the forum language does not affect the language of the email until you clear the setting value, and it will then be hard-coded to the current language again.

If you have multiple languages enabled, this means we can't use the benefit of the translator despite the email being translated by language packs.

Steps to Reproduce

  1. Enable extension, only customize bad words but don't set an email template
  2. Enable additional language, for example French
  3. Cause email to be sent for a first User using English. Email arrives in English
  4. Switch language to French in the header,
  5. Cause another email to be sent to the same or a different User while using the French forum. Email arrives in English again

Expected Behavior
When not setting a custom email template, the mail should be translated to the current or default forum locale, not the one that happened to send the very first mail and never change later.

Environment

  • Flarum version: 1.8.5
  • Extension version: 1.1.3, dev-master
  • Website URL: http://example.com
  • Webserver: apache
  • Hosting environment: local
  • PHP version: 8.1.28
Output of "php flarum info", run this in terminal in your Flarum directory.

Possible solution(s)
Rewrite code to not save the default translations to the database

Additional Context
The code has been rewritten over the years but it has always worked like this

// Admin hasn't saved an email template to the database
if (empty($this->settings->get('fof-filter.flaggedSubject'))) {
$this->settings->set(
'fof-filter.flaggedSubject',
$this->translator->trans('fof-filter.admin.email.default_subject')
);
}
if (empty($this->settings->get('fof-filter.flaggedEmail'))) {
$this->settings->set(
'fof-filter.flaggedEmail',
$this->translator->trans('fof-filter.admin.email.default_text')
);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant