Answers.Body: <p>Also - you can skip the capture... as the token is resolved first</p>
  <p>{if '{contact.preferred_language}' eq 'en_CA'}Spring cleaning on May 11th{else}Nettoyage du printemps le 11 mai{/if}</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-22T22:43:41.913Z
Answers.Text: Oh, this works! The characters saved should be enough to allow for bilingual subjects. Thanks!
Answers.UserDisplayName: Mathieu
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-22T21:49:53.843Z
Answers.LastActivityDate: 2024-04-22T21:49:53.843Z
Answers.UserDisplayName: eileen
Answers.Body: <p>You can create a language specific message template if you have the Message Admin extension enabled (it ships with Core)</p>
  <p>I just tested it with an Invoice &amp; my contact with Catalan language got the Catalan language when I used Download Invoice</p>
  <p>(I did have a funky moment on saving which I can't replicate - but the data is written to civicrm_translation)</p>
  <p><a href="https://i.sstatic.net/R7LuG.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/R7LuG.png" alt="enter image description here" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-22T22:42:37.497Z
Answers.Text: Interesting! Unfortunately the mailing is a custom mass mailing and not a system workflow message.
Answers.UserDisplayName: Mathieu
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-22T21:48:13.097Z
Answers.LastActivityDate: 2024-04-22T21:48:13.097Z
Answers.UserDisplayName: eileen
Body: <p>I am trying to make mailing subject lines automatically bilingual by using Smarty code, but I am running into an issue as the required code easily busts the 128 max character length for subject values.</p>
  <p>For example, this automatic bilingual subject value:</p>
  <pre><code>{capture assign=l}{contact.preferred_language}{/capture}{if $l eq 'en_CA'}Spring cleaning on May 11th{else}Nettoyage du printemps le 11 mai{/if}
  </code></pre>
  <p>Gives the error &quot;Value for subject is 145 characters - This field has a maxlength of 128 characters&quot;.  Of course the resulting subject text in the mailing will be much shorter, but the Smarty version is too long for CiviMail.</p>
  <p>I can only think of 2 ways to overcome this 128 character limitation:</p>
  <ul>
  <li>Change the subject field from a VARCHAR(128) to a VARCHAR(256) in the mailing DB table and it's matching maxlength value in the Mailing DAO code, but  that would be an ugly and unmanageable hack when upgrading.</li>
  <li>Find way to define a $lang Smarty variable in a global scope so it can be used in the subject line without having to &quot;capture&quot; the value directly in the subject line.  i.e. add this bit of code in a template somewhere <code>&quot;{capture assign=lang}{contact.preferred_language}{/capture}&quot;</code> so this bit of code is not necessary directly in the subject value.</li>
  </ul>
  <p>I can't be the only one who ran into this challenge.  How would you solve it?</p>
  <p>Thanks!</p>
  
Tags: <civimail><smarty>
Title: Mailing subject length when using Smarty
ThreadText: # Mailing subject length when using Smarty
  
  (Asked by: username_0 on 2024-04-22)
  
  I am trying to make mailing subject lines automatically bilingual by using Smarty code, but I am running into an issue as the required code easily busts the 128 max character length for subject values.
  For example, this automatic bilingual subject value:
  {capture assign=l}{contact.preferred_language}{/capture}{if $l eq 'en_CA'}Spring cleaning on May 11th{else}Nettoyage du printemps le 11 mai{/if}
  
  Gives the error "Value for subject is 145 characters - This field has a maxlength of 128 characters".  Of course the resulting subject text in the mailing will be much shorter, but the Smarty version is too long for CiviMail.
  I can only think of 2 ways to overcome this 128 character limitation:
  
  Change the subject field from a VARCHAR(128) to a VARCHAR(256) in the mailing DB table and it's matching maxlength value in the Mailing DAO code, but  that would be an ugly and unmanageable hack when upgrading.
  Find way to define a $lang Smarty variable in a global scope so it can be used in the subject line without having to "capture" the value directly in the subject line.  i.e. add this bit of code in a template somewhere "{capture assign=lang}{contact.preferred_language}{/capture}" so this bit of code is not necessary directly in the subject value.
  
  I can't be the only one who ran into this challenge.  How would you solve it?
  Thanks!
  
  **Tags:** civimail, smarty
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2024-04-22. Score: 2
  
  Also - you can skip the capture... as the token is resolved first
  
  {if '{contact.preferred\_language}' eq 'en\_CA'}Spring cleaning on May 11th{else}Nettoyage du printemps le 11 mai{/if}
  
  > **Comments:**
  > **username_0**: Oh, this works! The characters saved should be enough to allow for bilingual subjects. Thanks!  
  
  ---
  
  ### Answer by username_1 on 2024-04-22. Score: 0
  
  You can create a language specific message template if you have the Message Admin extension enabled (it ships with Core)
  
  I just tested it with an Invoice & my contact with Catalan language got the Catalan language when I used Download Invoice
  
  (I did have a funky moment on saving which I can't replicate - but the data is written to civicrm\_translation)
  
  [![enter image description here](https://i.sstatic.net/R7LuG.png)](https://i.sstatic.net/R7LuG.png)
  
  > **Comments:**
  > **username_0**: Interesting! Unfortunately the mailing is a custom mass mailing and not a system workflow message.  
  
  ---
  
  