CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Internationalization and Localization (Moderators: Michał Mach, mathieu) »
  • International audience
Pages: [1]

Author Topic: International audience  (Read 3693 times)

goran

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 3
International audience
September 22, 2009, 01:38:06 am
Hello (again),

A while ago I was looking at the possibility for CiviMail to choose from multiple messages/templates based on a custom field using smarty templates as this was scheduled for v2.3. I assume that it is now going to come into v3.0 (as described at http://civicrm.org/node/480; btw, where can one now check the targeted version for this feature?)

I wanted to take advantage of this feature so that I could use a single group and send messages in one go even though if we needed to translate them to multiple languages (for our shop this works well as we have only three official languages).

For example, assuming contact.custom_8 is preferred language

{if {contact.custom_8}=='S'}
Spanish text
{else  if {contact.custom_8}=='F')
French text
{else}
English text
{/if}

Or also it would be possible to adjust the formatting of addresses for differences between EU/US in mailing labels and letters.

Later I concluded that even though it would work, it would not be perfect since end users do get scared by curly brackets and that in the long term such a property as the preferred language for communication is quite an important piece of information for any truly international deployment of CiviCRM, so I am bringing it up here.

It could all still be internally done as above, but UI could reflect it for the end user.

Is anybody interested in this? Is http://civicrm.org/node/480 still on the roadmap?
 

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: International audience
September 22, 2009, 07:04:19 am

That was implemented and is part of 2.2 (and also 3.0)

To allow CiviMail to evaluate Smarty templates, you need to add the following  line to civicrm.settings.php:

  define( 'CIVICRM_MAIL_SMARTY', 1 );

There are no plans for the short/medium term releases to add more functionality to this. If interest to you/your org please consider developing and writing the code

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

goran

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 3
Re: International audience
September 23, 2009, 08:01:47 am
Thanks! :)

Any tips on on mixing smarty code and html in fckeditor?
It tends to escape the quotes even though I put them in source mode as soon as I switch to html
Is there a way to tell fckeditor not to touch the smarty code?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: International audience
September 23, 2009, 09:11:51 am

sorry no. I just did a web search to see if i can find something and did not get too many leads

can you keep us updated on this. In 3.1 we are moving all email templates to the database and it would be good for users to edit the html email via fckeditor/tinymce

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

goran

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 3
Re: International audience
September 24, 2009, 12:52:55 am
I will, but I am not optimistic (after thinking and looking into it a bit): these are html editors and what we have here is only mostly html (if I understand things correctly editing smarty tpl in html editors seems to be a much wider issue).

I think I will end up dealing either with source only to keep it simple and stupid or supporting my specific needs, which will be nice on user but very particular solution - supporting something like:

{if "{contact.custom_8}"=="value1"}
$html1
{elseif "{contact.custom_8}"=="value2"}
$html2...
{else}
$htmln
{/if}

where user is presented with n html areas for entering variants of the messages and the above template is evaluated to produce final smarty/html (in my case n would be a fixed number).

More universal solution could be to provide possibility to enter the smarty itself as text and reference html bits from within it, then edit html portions in html editor and then preparse/evaluate the smarty that would be used to parse the final message (all of which sounds a bit over-complicated and might partition html in a not such a nice way, but i think we come back to the problem of html editors which are not able to gracefully deal with non-html content).

Can't say at present when and if I'll have time to do any of this, but will keep you posted if any work will be done on it.

goran

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 3
Re: International audience
September 24, 2009, 08:52:32 am
After a bit more digging I found that fckeditor has

FCKConfig.ProtectedSource.Add Regex

see http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options/ProtectedSource.Add

which should go into civicrm/packages/fckeditor/fckconfig.js

Will test it later.

Also, let me check on another issue. My e-mail templates (well, headers actually) have css styles and smarty processor didn't like running into a thing like

p {font-family:"font";}

however it did send out the message, just it produced quite an overwhelming warning. I guess I can not do anything about this?
« Last Edit: September 24, 2009, 08:55:36 am by goran »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: International audience
September 24, 2009, 10:16:07 am
Quote from: goran on September 24, 2009, 08:52:32 am
p {font-family:"font";}

the above should be written as:

Code: [Select]
{literal}
p {font-family:"font";}
{/literal}

Smarty does not evaluate anything within the literal tags

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

goran

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 3
Re: International audience
December 09, 2009, 08:13:24 am
I have finally found time (was pressed) to test this a bit more.
Of course it was more complicated then one would anticipate - smarty does nested brackets (of course) and javascript regex is not really great for doing balanced or recursive regexes as I've learned.

Anyway, here's the line for fckconfig.js that I've tested and found satisfactory for now...

FCKConfig.ProtectedSource.Add( /{(?:[^{}]|{[^{}]*})*}/g ) ; // Smarty - (!) this supports only one level of nesting for curly brackets

This will hide smarty bits in html mode ( regex slightly modified from http://blog.stevenlevithan.com/archives/regex-recursion ).
Of course it will see anything within brackets as smarty code and it will hide it during editing (but at least it will not escape it - which made smarty code in html section containing any of the characters that are escaped in html impossible to save in civicrm).

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Internationalization and Localization (Moderators: Michał Mach, mathieu) »
  • International audience

This forum was archived on 2017-11-26.