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) »
  • Using CiviCRM in a multilingual environment
Pages: [1]

Author Topic: Using CiviCRM in a multilingual environment  (Read 6968 times)

dkoffler

  • Guest
Using CiviCRM in a multilingual environment
February 25, 2008, 09:05:42 pm
What are the current best practices with regards to using CiviCRM 2.0 in a multilingual site? I read the posts about the attempted CiviLingua project which has died.

I was wondering if it would be possible to have 2 separate instances of CiviCRM, both pointing to the same database, but one setup in French and one in English. I realize this is porbably not possible within the same Drupal site, but what if I created a second Drupal site just to host my alternate language CiviCRM installation?

Any thoughts on this would be greatly appreciated.

Michał Mach

  • Moderator
  • Ask me questions
  • *****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: Using CiviCRM in a multilingual environment
February 26, 2008, 07:33:45 am
Quote from: dkoffler on February 25, 2008, 09:05:42 pm
What are the current best practices with regards to using CiviCRM 2.0 in a multilingual site? I read the posts about the attempted CiviLingua project which has died.

There is a few organisations which made this kind of attempts, so perhaps they'll share their experience here on the forum. From technical point of view, CiviCRM currently provides ability to use single UI language per instance and no core support for multiligual data. Along with other architecture changes, we will be moving towards having "per session" language, but that's still quite far away, unless there is an funded project which would require this.

Quote from: dkoffler on February 25, 2008, 09:05:42 pm
I was wondering if it would be possible to have 2 separate instances of CiviCRM, both pointing to the same database, but one setup in French and one in English. I realize this is porbably not possible within the same Drupal site, but what if I created a second Drupal site just to host my alternate language CiviCRM installation?

I wouldn't risk using single database for two CiviCRM instances, it wasn't built for tihs. For instance, modifying data in one instance and querying for it in second could cause pretty unexpected problems.

Thx,
m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Using CiviCRM in a multilingual environment
February 26, 2008, 11:52:50 am
One of the critical blockers here - in case it wasn't clear from Michal's post - is that the database contains a large number of strings which need to be localised. For example, civicrm_option_value stores labels for Gender, Activity Type, Location Type and .... The current architecture doesn't support storing multiple localised versions of these labels.
Protect your investment in CiviCRM by  becoming a Member!

dkoffler

  • Guest
Re: Using CiviCRM in a multilingual environment
February 27, 2008, 10:19:19 am
Ok, I understand the problem with storing multiple localization strings in the DB.

I had already decided not to use the CiviCRM events and mailer based on the lack of multilinugal support. As far as profile fields, I just created the labels in a multilingual format (ex: Ms. | Mme. ) which although less than ideal is ok for now.

I don't really care about a full multilingual implementation (all the backend stuff can be in one language), but I would REALLY like to use CiviContribute and have a contribution page for each language. I have done this, but obviously things such as field labels only show up in the main CiviCRM language.

I am now thinking of hacking together a new .po file that has multilingual strings where I need them.

If anyone has already done this for Canadian French + English, please let me know.

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: Using CiviCRM in a multilingual environment
February 27, 2008, 12:41:42 pm

some hacks which the civicactions folks did for amnesty and which seems to work quite well is:

1. Redefine ts, to pass thru the drupal translator t( ) if defined:

https://svn.civicactions.net/repos/civicrm/branches/v1.8-amnesty/CRM/Core/I18n.php

2. Send a few of the db string (profile field names, intro text etc) to the civicrm ts( ) function (which in turn passes it to drupal t( ))

using the above combination they were able to display civicrm public pages using multiple languages. I dont know how much they had to hack, but i suspect they modified a fair amount of 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

wmostrey

  • I post occasionally
  • **
  • Posts: 36
  • Karma: 3
    • Wim Mostrey
Re: Using CiviCRM in a multilingual environment
March 03, 2008, 12:29:07 am
Apart from the modification to the ts() function, most adjustments were in the theme really, mostly in these files (so just put these files in your theme directory and make sure to adjust the "url sources" setting):

Profile/Form/Dynamic.tpl
Profile/Page/Dynamic.tpl
UF/Form/Block.tpl
Contribute/Form/Contribution/Confirm.tpl
Contribute/Form/Contribution/Main.tpl
Contribute/Form/Contribution/MembershipBlock.tpl
Contribute/Form/Contribution/ThankYou.tpl

There are 2 or 3 places in the code where we needed to force ts() around some variables and those are being documented as we prepare for the CiviCRM 2.0 migration. I'll be sure to post these as I document more information.

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: Using CiviCRM in a multilingual environment
March 04, 2008, 05:19:20 pm
Hi,

We also used the method described above to translate CiviContribute pages in english and fr_CA. Apart from what was said above, we had to make sure that the URLs to the donations pages include the language for Drupal, and we had setup two different contribution pages, one for each language. Ah, and we had the same set of custom fields, but we used different profiles to translate the fields.

For example:

https://www.muhcfoundation.com/en/civicrm/contribute/transact?reset=1&id=1
https://www.muhcfoundation.com/fr/civicrm/contribute/transact?reset=1&id=9

Finally, in order to reduce the quantity of strings managed by Drupal, we limited the strings which were passed through t() by checking if we were in a civicontribute page:

In CRM/Core/I18n.php :


function ts($text, $params = array())
{
    if ($text == '') {
        return '';
    }

    if ( ! $GLOBALS['_CRM_CORE_I18N']['i18n'] ) {
        $GLOBALS['_CRM_CORE_I18N']['i18n'] =& CRM_Core_I18n::singleton();
    }

        // [ML] 2007-11-28
        // If locale is French and if in "CiviContribute", pass strings in Drupal's t()
        global $locale;
        if ($locale == 'fr' && arg(1) == 'contribute') {
                $text = t($text);
        }

        return $GLOBALS['_CRM_CORE_I18N']['i18n']->crm_translate($text, $params);
}


This is with a CiviCRM 1.8 running on PHP4.

On the down side, it's a patch to the core and it's not very elegant. Would it be possible to add a bit of code in the core which would check for a callback (ex: if function_exists('custom_ts') custom_ts($text, $array)) ? We have a few sites which are going to run into this problem as well.

mathieu (bgm on freenode)
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

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: Using CiviCRM in a multilingual environment
March 04, 2008, 09:33:06 pm

mathieu:

1. can you please file an issue for this. We'll enable this in 2.1

2. I suspect we'll do it similar to the fatal error handler mechanism. i.e. allow the user to set an additional 'ts' function in the config settings.

http://drupal.demo.civicrm.org/civicrm/admin/setting/debug?reset=1

(we'll do this in the localization settings though)

One thing which we dont do, and which we should potentially consider doing, is to allow "some" db fields to be translated on the fly. This is at least applicable to profile field labels which are displayed in public pages. This should allow folks to reuse the same contribution page under a different context. This might ba an hack to get around some of our most pressing multi-lingual issues

lobo

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

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: Using CiviCRM in a multilingual environment
March 05, 2008, 02:40:51 pm
Thanks lobo, that sounds great.

I have opened issue CRM-2808.

matt
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: Using CiviCRM in a multilingual environment
March 06, 2008, 06:29:53 am
Thanks for filling this issue, Matt. I’ll work on it for 2.1.

Quote from: Donald Lobo on March 04, 2008, 09:33:06 pm
One thing which we don’t do, and which we should potentially consider doing, is to allow “some” db fields to be translated on the fly. This is at least applicable to profile field labels which are displayed in public pages. This should allow folks to reuse the same contribution page under a different context. This might be an hack to get around some of our most pressing multi-lingual issues

Just for the record – if these fields are MySQL’s enums, then the relevant DAO already has tsEnum() and addDisplayEnums() calls that can be used in the proper page’s/form’s PHP file. If these are not enums (but, say, civicrm_option_value entries), we might want to consider doing something similar.
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Internationalization and Localization (Moderators: Michał Mach, mathieu) »
  • Using CiviCRM in a multilingual environment

This forum was archived on 2017-11-26.