Answers.Body: <p>I got it:</p>
  
  <p>{if $tsLocale eq 'es_ES'}
      <p>Spanish string
  {else}
      <p>Catalan string
  {/if}</p>
  
  <p>An easy way, useful to translate custom form strings used once, for example ;-)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-08T17:16:39.857Z
Answers.LastActivityDate: 2018-01-08T17:16:39.857Z
Answers.UserDisplayName: calbasi
Answers.Body: <p>It sounds like you're trying to translate a string, so using <code>{ts}</code> is the way to go.  There's a nice <a href="https://civicrm.org/blog/spidersilk/how-to-edit-your-own-sites-civicrm-translation-files" rel="nofollow noreferrer">blog post about creating local translation files</a> that should help you prepare the Catalan one.  </p>
  
  <p>Three caveats:</p>
  
  <ul>
  <li><p>You'll need to add your new string to the file that you get from CiviCRM, since it's not going to know about your customization.</p></li>
  <li><p>As new versions of CiviCRM come out, you'll need to get an updated translation file and reapply your change.</p></li>
  <li><p>Strictly speaking, the assumption is that the string wrapped in <code>{ts}</code> is US English, so you'd be normally expected to set the English one there and then translate it to Spanish and Catalan in separate local translation files, but assuming you're defaulting to Spanish on your site and not offering English, I don't think it would be a problem to have <code>{ts}</code> wrap a Spanish string and then set up your local translation file as Spanish-to-Catalan rather than English-to-Catalan.  That means you only have to customize the Catalan file.</p></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-08T15:48:21.010Z
Answers.Text: Hi @andrew-hunt ,
  
  But this is a very complex way just to translate an string in a cursom form template! It's, in fact, easier, to use some type of php logics to render a Catalan or Spanish text depending on a language variable...
  
  I mean, if I would be doing an extension / custom module, well, I think this way could be more consistent thant just a few php lines, because I can add my custom extension translation files with my custom module. But I'm just trying to add a custom footnote in a form, to be impressed when printing in paper... I've got it in Catalan, and just trying to translate
Answers.UserDisplayName: calbasi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-08T16:04:44.847Z
Answers.Text: By the way @pradeep-nayak , andrew-hunt :
  I like use a simple solution like this:
  [https://stackoverflow.com/a/8355986]
Answers.UserDisplayName: calbasi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-05T17:31:59.820Z
Answers.LastActivityDate: 2018-01-05T17:31:59.820Z
Answers.UserDisplayName: Andie Hunt
Answers.Body: <p>If you need CiviCRM to translate the string then you should use <code>{ts}String to display{/ts}</code>. In your case i believe the string should not translate so do not use {ts} tag. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-08T15:52:35.807Z
Answers.Text: In drupal I can add a custom translatable string in a php file and system recognize it and let me translate it using string translation system. For example in a custom module.
  But if this can't be achieved in civicrm, I like just use a php logic process if/else to catch active language and use its related string... I don't need use general civicrm localization .po files!
  Just wondering what's the easy way to do it...
Answers.UserDisplayName: calbasi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-05T12:10:03.970Z
Answers.LastActivityDate: 2018-01-05T12:10:03.970Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>I'm using a custom profile template. I need display different text strings depending on browser language of user... One string for Spanish users and other string for all other users.</p>
  
  <p>It seems this doesn't run:</p>
  
  <p>{if $la eq 'es'}
      <p>Spanish string
  {else}
      <p>Catalan string
  {/if}</p>
  
  <p>Mybe using {ts} tag? But I don't know where I should translate {ts strings}</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-05T12:11:06.107Z
Comments.Text: are you using the snippet in .tpl file? What $l will hold?
Comments.UserDisplayName: Pradeep Nayak
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-08T15:40:51.450Z
Comments.Text: Yes, I'm using the snippet in a custom profile .tpl file... And $l is an error, I mean $la (but I don't know which variable has language information, even if there are any variable to catch it in civicrm custom templates.
Comments.UserDisplayName: calbasi
Tags: <smarty><templates><i18n><translation>
Title: Show translated string in a template field (using smarty?)
ThreadText: # Show translated string in a template field (using smarty?)
  
  (Asked by: username_0 on 2018-01-05)
  
  I'm using a custom profile template. I need display different text strings depending on browser language of user... One string for Spanish users and other string for all other users.
  
  It seems this doesn't run:
  
  {if $la eq 'es'}
  
  Spanish string
  {else}
  
  Catalan string
  {/if}
  
  Mybe using {ts} tag? But I don't know where I should translate {ts strings}
  
  **Tags:** smarty, templates, i18n, translation
  
  > **Comments:**
  > **username_1**: are you using the snippet in .tpl file? What $l will hold?  
  > **username_0**: Yes, I'm using the snippet in a custom profile .tpl file... And $l is an error, I mean $la (but I don't know which variable has language information, even if there are any variable to catch it in civicrm custom templates.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2018-01-08. Score: 3
  
  I got it:
  
  {if $tsLocale eq 'es\_ES'}
  
  Spanish string
  {else}
  
  Catalan string
  {/if}
  
  An easy way, useful to translate custom form strings used once, for example ;-)
  
  
  ---
  
  ### Answer by username_2 on 2018-01-05. Score: 1
  
  It sounds like you're trying to translate a string, so using `{ts}` is the way to go. There's a nice [blog post about creating local translation files](https://civicrm.org/blog/spidersilk/how-to-edit-your-own-sites-civicrm-translation-files) that should help you prepare the Catalan one.
  
  Three caveats:
  
  * You'll need to add your new string to the file that you get from CiviCRM, since it's not going to know about your customization.
  * As new versions of CiviCRM come out, you'll need to get an updated translation file and reapply your change.
  * Strictly speaking, the assumption is that the string wrapped in `{ts}` is US English, so you'd be normally expected to set the English one there and then translate it to Spanish and Catalan in separate local translation files, but assuming you're defaulting to Spanish on your site and not offering English, I don't think it would be a problem to have `{ts}` wrap a Spanish string and then set up your local translation file as Spanish-to-Catalan rather than English-to-Catalan. That means you only have to customize the Catalan file.
  
  > **Comments:**
  > **username_0**: Hi @andrew-username_2 ,  But this is a very complex way just to translate an string in a cursom form template! It's, in fact, easier, to use some type of php logics to render a Catalan or Spanish text depending on a language variable...  I mean, if I would be doing an extension / custom module, well, I think this way could be more consistent thant just a few php lines, because I can add my custom extension translation files with my custom module. But I'm just trying to add a custom footnote in a form, to be impressed when printing in paper... I've got it in Catalan, and just trying to translate  
  > **username_0**: By the way @username_1 , andrew-username_2 : I like use a simple solution like this: [https://stackoverflow.com/a/8355986]  
  
  ---
  
  ### Answer by username_1 on 2018-01-05. Score: 0
  
  If you need CiviCRM to translate the string then you should use `{ts}String to display{/ts}`. In your case i believe the string should not translate so do not use {ts} tag.
  
  > **Comments:**
  > **username_0**: In drupal I can add a custom translatable string in a php file and system recognize it and let me translate it using string translation system. For example in a custom module. But if this can't be achieved in civicrm, I like just use a php logic process if/else to catch active language and use its related string... I don't need use general civicrm localization .po files! Just wondering what's the easy way to do it...  
  
  ---
  
  