Answers.Body: <p>When using a frontend form to create a new user it is actually straight forward, because you can easily send a <code>preferredLanguage</code> attribute with the request that sets the language on creation (see <a href="https://github.com/craftcms/cms/blob/d754d673f2ee8dd2b914f3d1cb4db462fd0da0e3/src/controllers/UsersController.php#L1285" rel="nofollow noreferrer">this line in the user controller</a>). However, if you want to use the CP form to create a user, there doesn't seem to be an out of the box solution for your problem. Here is what you could try:</p>
  <p>There is a <a href="https://github.com/craftcms/cms/blob/d754d673f2ee8dd2b914f3d1cb4db462fd0da0e3/src/templates/users/_edit.html#L315" rel="nofollow noreferrer">template hook</a> in the user edit template. You could use this to inject an input that sets the preferred language. You could even show that input for new users only. In the simplest case it could look something like this:</p>
  <pre><code>&lt;input type=&quot;text&quot; name=&quot;preferredLanguage&quot; value=&quot;de&quot;&gt;
  </code></pre>
  <p>You surely would want to have a select or something with the available languages. To inject the markup into that template you would have to create a module or plugin and then follow the <a href="https://craftcms.com/docs/3.x/extend/template-hooks.html" rel="nofollow noreferrer">docs for template hooks</a>.</p>
  <p>PS: If you wonder where the user language is stored, it has an extra table called <code>userpreferences</code> storing stuff like this in JSON format.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-06-07T14:00:46.723Z
Answers.Text: This behavior changed since Craft 4.x for some reason and only works for logged-in users [as seen here](https://github.com/craftcms/cms/blob/4.x/src/controllers/UsersController.php#L1498).
  
  This means…
  `<input type="text" name="preferredLanguage" value="de">`
  …doesn’t do anything for newly created users.
  
  @bradbell any chance to get that functionality back in Craft 4.x? I’d need that in order to decide in which language I should create automated emails to front-end-only-users on my multi-site project.
Answers.UserDisplayName: medoingthings
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-29T08:02:42.893Z
Answers.LastActivityDate: 2021-05-29T08:02:42.893Z
Answers.UserDisplayName: Johannes
Body: <p>I'm trying to figure out how to set the default language for new users and user activation emails. I have found the <a href="https://craftcms.com/docs/3.x/config/config-settings.html#defaultcplanguage" rel="nofollow noreferrer">defaultCPLanguage</a> config setting which does indeed change the default language of new accounts created through the backend. However, the activation email doesn't use that default language. Based on testing I have determined that the account activation email will be sent in the language that the user creating the new account has set in their account preferences. So if I create a new user account with my admin account, which is set to English, the activation email will be in English as well. If I set my language preference to German, the activation mail will be in German.</p>
  <p>Is there a way to change this? The CP doesn't provide a way to change the language preference of a new account. I would prefer it if the activation mail always used the language set as <code>defaultCpLanguage</code>.</p>
  <p><strong>Edit:</strong> The following is a <a href="https://github.com/craftcms/cms/issues/7992" rel="nofollow noreferrer">confirmed bug and will be fixed in the next release</a>!</p>
  <p>As a sidenote, the templates for account emails are editable from Utilities -&gt; System Messages. However, I can only edit those templates for my current language preference. To edit the messages in a different language, I have to set my account preference to that language first. This is weird and unintuitive. Is there a better way to edit System Messages across different languages? Or at least have the System Messages tab always display the messages in the <code>defaultCpLanguage</code>?</p>
  
Tags: <emails><language><activation>
Title: Force specific language for user activation mail and edit localized email templates
ThreadText: # Force specific language for user activation mail and edit localized email templates
  
  (Asked by: username_0 on 2021-05-26)
  
  I'm trying to figure out how to set the default language for new users and user activation emails. I have found the [defaultCPLanguage](https://craftcms.com/docs/3.x/config/config-settings.html#defaultcplanguage) config setting which does indeed change the default language of new accounts created through the backend. However, the activation email doesn't use that default language. Based on testing I have determined that the account activation email will be sent in the language that the user creating the new account has set in their account preferences. So if I create a new user account with my admin account, which is set to English, the activation email will be in English as well. If I set my language preference to German, the activation mail will be in German.
  
  Is there a way to change this? The CP doesn't provide a way to change the language preference of a new account. I would prefer it if the activation mail always used the language set as `defaultCpLanguage`.
  
  **Edit:** The following is a [confirmed bug and will be fixed in the next release](https://github.com/craftcms/cms/issues/7992)!
  
  As a sidenote, the templates for account emails are editable from Utilities -> System Messages. However, I can only edit those templates for my current language preference. To edit the messages in a different language, I have to set my account preference to that language first. This is weird and unintuitive. Is there a better way to edit System Messages across different languages? Or at least have the System Messages tab always display the messages in the `defaultCpLanguage`?
  
  **Tags:** emails, language, activation
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-05-29. Score: 2 | Accepted answer
  
  When using a frontend form to create a new user it is actually straight forward, because you can easily send a `preferredLanguage` attribute with the request that sets the language on creation (see [this line in the user controller](https://github.com/craftcms/cms/blob/d754d673f2ee8dd2b914f3d1cb4db462fd0da0e3/src/controllers/UsersController.php#L1285)). However, if you want to use the CP form to create a user, there doesn't seem to be an out of the box solution for your problem. Here is what you could try:
  
  There is a [template hook](https://github.com/craftcms/cms/blob/d754d673f2ee8dd2b914f3d1cb4db462fd0da0e3/src/templates/users/_edit.html#L315) in the user edit template. You could use this to inject an input that sets the preferred language. You could even show that input for new users only. In the simplest case it could look something like this:
  
  ```
  <input type="text" name="preferredLanguage" value="de">
  
  ```
  
  You surely would want to have a select or something with the available languages. To inject the markup into that template you would have to create a module or plugin and then follow the [docs for template hooks](https://craftcms.com/docs/3.x/extend/template-hooks.html).
  
  PS: If you wonder where the user language is stored, it has an extra table called `userpreferences` storing stuff like this in JSON format.
  
  > **Comments:**
  > **username_2**: This behavior changed since Craft 4.x for some reason and only works for logged-in users [as seen here](https://github.com/craftcms/cms/blob/4.x/src/controllers/UsersController.php#L1498).  This means… `<input type="text" name="preferredLanguage" value="de">` …doesn’t do anything for newly created users.  @bradbell any chance to get that functionality back in Craft 4.x? I’d need that in order to decide in which language I should create automated emails to front-end-only-users on my multi-site project.  
  
  ---
  
  