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) »
  • CiviCRM 2.1 Alpha Fatal error: Cannot redeclare ts()
Pages: [1]

Author Topic: CiviCRM 2.1 Alpha Fatal error: Cannot redeclare ts()  (Read 7240 times)

jarvar

  • Guest
CiviCRM 2.1 Alpha Fatal error: Cannot redeclare ts()
August 07, 2008, 07:40:22 am
Hello everyone,
I am developing a Website for a Community organization that requires multiple languages so I am using the i18n module for Drupal 6. After installing CiviCRM 2.1 Alpha, I get this error when navigating to certain sections of the Drupal Admin such as Modules:

Fatal error: Cannot redeclare ts() (previously declared in /home/iwcc3399/public_html/drupal/sites/all/modules/i18n/i18nstrings/i18nstrings.module:89) in /home/iwcc3399/public_html/drupal/sites/all/modules/civicrm/CRM/Core/I18n.php on line 348

I got an answer from Piotr Szotkowski that:

"You're not supposed to redeclare ts(), you're supposed to declare your_own_ts() and set it in the Administer CiviCRM pages - all calls to ts() will get then re-routed to your_own_ts()."

Can someone help me out with this problem?
Thank you very much.

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: CiviCRM 2.1 Alpha Fatal error: Cannot redeclare ts()
August 08, 2008, 02:42:02 am
Argh, sorry, I understood that you have your own ts() function, not one from another module.

It looks like the i18n module also had the same idea as CiviCRM – that ‘ts’ is a good, short function name. :(

Can you try confirming this by disabling the i18n module for a moment and seeing whether CiviCRM starts working then?
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.

jarvar

  • Guest
Re: CiviCRM 2.1 Alpha Fatal error: Cannot redeclare ts()
August 09, 2008, 08:52:21 am
Hi Piotr
well the thing is, I am unable to access the Modules Admin pages as well as some others when both modules (i18n and CiviCRM) are enabled. If I delete CiviCRM then it works. However, I managed to edit out some code or atleast disable the function I believe within the i18nstrings.module
( i18n/i18nstrings/i18nstrings.module). I changed it back and have been unable to find the script which I disabled.
When it was disabled, I was able to use CiviCRM through the url like drupal/civicrm but not through the administer pages.
Thank you very much for your help.

I am off from work today so I will see if I can repeat the behaviour.
Any idea which scripts I could disable?

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: CiviCRM 2.1 Alpha Fatal error: Cannot redeclare ts()
August 09, 2008, 10:49:26 am
You can try disabling the i18n module; if you can’t access Drupal’s admin pages, you can just disable it by going to the system table of your Drupal’s database and setting the status column to 0 in the row related to the i18n module.
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.

jarvar

  • Guest
Re: CiviCRM 2.1 Alpha Fatal error: Cannot redeclare ts()
August 09, 2008, 12:22:36 pm
Okay, I have had some time now.
I disabled all i18n modules and CiviCRM worked. Also I thought the most recent SVN would fare better, but it appears that there are some differences, or I am not doing it properly.
So I also reinstalled the 2.1 alpha 1. Upon disabling all i18n modules, the admin pages were accessible and CiviCRM was accessible.
I took the next step and enabled ONLY the i18n module and all the others disabled. So far it continues to work. I also enabled the i18n blocks module.module

I will keep trying I guess until it breaks.

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: CiviCRM 2.1 Alpha Fatal error: Cannot redeclare ts()
August 09, 2008, 02:06:59 pm
Well, from your previous reports the situation is quite clear – the i18nstrings module declares the ts() function (in PHP’s global namespace), as does CiviCRM – which means these two simply can’t be used together.

I’m not sure what a sane and future-proof workaround could be; the idea behind string-localising functions is that their names are as short as possible (Drupal itself uses t(), gettext’s default is _()), hence our (and i18nstrings’s) ts(). If we switched to any other one- or two-letter name, we’ll just risk clashing with other PHP code that gets the same idea.

I’ll ponder on how to make CiviCRM work along with i18nstrings, but nothing simple/obvious comes to my mind at the moment. :|
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.

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: CiviCRM 2.1 Alpha Fatal error: Cannot redeclare ts()
August 09, 2008, 11:37:24 pm

I think someone (dave lange?) filed an issue with that module sometime ago requesting a name change of the function. You might want to follow up on that

Ultimately one of the modules needs to rename the function "ts" if there are a fair number of users using both. Our argument is: "we chose that function name first!". Not sure if PHP namespace (in PHP 5.3?) will fix this issue

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

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: CiviCRM 2.1 Alpha Fatal error: Cannot redeclare ts()
August 10, 2008, 05:25:01 am
Quote from: Donald Lobo on August 09, 2008, 11:37:24 pm
I think someone (Dave Lange?) filed an issue with that module sometime ago requesting a name change of the function. You might want to follow up on that

There was an issue with the Localizer module, and they renamed their ts().

Quote from: Donald Lobo on August 09, 2008, 11:37:24 pm
Ultimately one of the modules needs to rename the function "ts" if there are a fair number of users using both. Our argument is: "we chose that function name first!". Not sure if PHP namespace (in PHP 5.3?) will fix this issue

Seems a sensible solution (and you’re right, namespaces are part of PHP 5.3 alpha1 and should solve this; they’re planning to have 5.3 stable by mid October).
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.

jarvar

  • Guest
Re: CiviCRM 2.1 Alpha Fatal error: Cannot redeclare ts()
August 10, 2008, 08:08:31 am
I did read about the fix with localizer.
I am wondering whether or not someone used CiviCRM with i18n in Drupal 5? or whether this is a new issue.

Also is localizer a better option for multlingual sites?
I will probably need approximately three languages. French, English and possibly Tamil and Spanish. I beleive I used it in Drupal 5, but I went with i18n because it was already available for Drupal6. It also seems to do what I want so far. Are there better options?

Any way on how to implement the change around the localizer.ts  for i18n?
I also remember reading somewhere Amnesty International had a work around a while back. I think back in the 1.9 version of CiviCRM. It was unclear to me however how they actually did that.

Hopefully you can tell, but I am quite new with all this stuff. I know my way around a few web languages, but mostly html.
Thank you for the help so far.

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: CiviCRM 2.1 Alpha Fatal error: Cannot redeclare ts()
August 11, 2008, 12:11:04 am
Quote from: jarvar on August 10, 2008, 08:08:31 am
I am wondering whether or not someone used CiviCRM with i18n in Drupal 5? or whether this is a new issue.

I don’t think anybody on the CiviCRM team used either i18n or Localizer.

Quote from: jarvar on August 10, 2008, 08:08:31 am
Also is localizer a better option for multilingual sites?

I have no idea. One one hand, it still doesn’t have a Drupal 6 version, on the other – it doesn’t conflict with CiviCRM. Both Localizer and i18n have had releases in the past three days.

Quote from: jarvar on August 10, 2008, 08:08:31 am
I will probably need approximately three languages. French, English and possibly Tamil and Spanish. I believe I used it in Drupal 5, but I went with i18n because it was already available for Drupal 6. It also seems to do what I want so far. Are there better options?

None that I’m aware of (but I don’t have any experience with setting up multi-language Drupal sites). We’re introducing the initial version of multi-language support in CiviCRM 2.1, though.

Quote from: jarvar on August 10, 2008, 08:08:31 am
Any way on how to implement the change around the localizer.ts for i18n?

You can try checking what exactly does i18nstrings do with their ts() function calls and try renaming everything – whether this approach works depends on whether they assume any external modules call i18nstrings’ ts() function or not.
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.

seanwatters

  • I’m new here
  • *
  • Posts: 1
  • Karma: 0
Re: CiviCRM 2.1 Alpha Fatal error: Cannot redeclare ts()
October 20, 2008, 01:32:03 pm
Alright... the board seems to have eaten my last post.

At any rate, here is a simple patch to rename i18n's ts function to i18n_ts. It hasn't been tested thoroughly, but it seems to work for me and avoids the collision.

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: CiviCRM 2.1 Alpha Fatal error: Cannot redeclare ts()
December 28, 2008, 02:21:06 pm
I confirm the renaming to i18n_ts() solution - it's working for me.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Internationalization and Localization (Moderators: Michał Mach, mathieu) »
  • CiviCRM 2.1 Alpha Fatal error: Cannot redeclare ts()

This forum was archived on 2017-11-26.