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) »
  • How to send receipts in language of the contact
Pages: [1]

Author Topic: How to send receipts in language of the contact  (Read 1177 times)

tomb

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 7
  • MySQL version: 5.1
  • PHP version: 5.3
How to send receipts in language of the contact
May 14, 2014, 03:10:48 am
We have a multilingual installation with 3 languages.
We are using the contribution pages, but the receipts are being sent out in English (the site language) instead of the language of the contact.

How do I make CiviCRM use the language of the contact for sending out the receipts?


  • CiviCRM 4.4.4
  • Drupal 7
  • Inherit CMS Language
  • In Drupal the language detection is set to 'session parameter'

Luciano S.

  • I post occasionally
  • **
  • Posts: 83
  • Karma: 2
  • iXiam Team Leader
  • CiviCRM version: 4.2+ / 4.3+ / 4.4+
  • CMS version: Drupal
  • MySQL version: 5.1+ / 5.5+
  • PHP version: 5.3+ / 5.4+
Re: How to send receipts in language of the contact
May 14, 2014, 03:29:40 am
Hello tomb,

At the moment there is no feature to send receipts (or mailings) in different languages.
There are only 1 receipt template in English, that you can modified, but always it will be sent the same.
A workaround is to edit this template an add the texts in the 3 languages, not very tidy but could work

To modify the receipt template you can go to Administer / Communications / Message Templates / System Workflow Messages

Contributions - Receipt (on-line) template should be the one

tomb

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 7
  • MySQL version: 5.1
  • PHP version: 5.3
Re: How to send receipts in language of the contact
May 14, 2014, 03:37:01 am
I am able to send out the receipts in other languages if:
- i change the language of my civicrm session
- do a search for contributions
- and choose as action "Print or Email Contribution Receipts"

Both the email and the PDF with the receipt are then translated.

So civicrm is able to generate the receipts in other languages. The only thing missing is making it use the "contact preferred language" instead of the language of the civicrm session.

mathieu

  • Administrator
  • Ask me questions
  • *****
  • Posts: 620
  • Karma: 36
    • Work
  • CiviCRM version: 4.7
  • CMS version: Drupal
  • MySQL version: MariaDB 10
  • PHP version: 7
Re: How to send receipts in language of the contact
May 16, 2014, 03:17:44 pm
This is indeed a limitation of CiviCRM and the topic has come up a few times. It also affects, for example, membership renewal emails, and other scheduled reminders.

We have a bit of refactoring to do in the core code that sets the user language, but other than that, it might be relatively straight forward to set the language in the various places that send e-mails (I haven't looked, but there should not be that many places, especially since most mails usually go through message templates). I'm not sure for the printing of receipts, but presumably it also goes through messages templates?

If you would like to work on the issue, I would be more than happy to provide guidance / test patches. If not, it is a task that has been on my queue for a while, but not my highest priority, and slightly too big of a task for my spare volunteer time. Would there be an interest in creating a "make it happen" initiative and co-fund the development? (https://civicrm.org/make-it-happen)
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

tomb

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 7
  • MySQL version: 5.1
  • PHP version: 5.3
Re: How to send receipts in language of the contact
May 20, 2014, 05:09:37 am
The receipts are sent throught message templates yes.

I don't have experience with patching Civi code. But maybe you can provide some tips with where and how this should be done, and I can see if I am able to do something.

Even a quick hack, like setting language through the theme's template.php or something like that would be ok for me.

mathieu

  • Administrator
  • Ask me questions
  • *****
  • Posts: 620
  • Karma: 36
    • Work
  • CiviCRM version: 4.7
  • CMS version: Drupal
  • MySQL version: MariaDB 10
  • PHP version: 7
Re: How to send receipts in language of the contact
May 20, 2014, 07:12:59 am
I'm not sure that a quick hack is possible in this case, but it should not be too complicated, and worth the investment, since lots of functions of civicrm could benefit from working on this. The language is used in a few places:

* in many parts, the global variable $tsLocale is used for i18n stuff
* in other parts, $config->lcMessages is used (from the CRM_Core_Config singleton)
* the smarty template compilation/cache directory (template_c) will also affect translation, so it must be changed too when $tsLocale is changed
* the global $dbLocale variable determines from which SQL view to query
* and finally, phpgettext gets initialized with a language-specific civicrm.mo (it's easier with "native gettext", see CRM/Core/I18n.php's contruct).

I would probably create a new function in CRM/Core/I18n.php to deal with language changes (depending on how early the I18n singleton is initialized in CRM_Core_Config.

Then CRM_Core_BAO_MessageTemplate::sendTemplate() is probably the best place to lookup the $contact_id's preferred language and switch the language for each contact (and making sure to reset back the language after the message template has been processed).

NB: when in CiviCRM it is written, for example, CRM_Core_BAO_MessageTemplate, it translates to the file CRM/Core/BAO/MessageTemplate.php. The developer docs have more info: http://wiki.civicrm.org/confluence/display/CRMDOC/Develop
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Internationalization and Localization (Moderators: Michał Mach, mathieu) »
  • How to send receipts in language of the contact

This forum was archived on 2017-11-26.