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) »
  • Anyone using Word Replacement?
Pages: [1]

Author Topic: Anyone using Word Replacement?  (Read 1453 times)

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Anyone using Word Replacement?
May 12, 2011, 02:43:39 am
Is anyone out there actually using the Word Replacement functionality? I never get it to work on my Dutch installs and get the warning
Quote
Notice: Undefined offset: 2 in CRM_Admin_Form_WordReplacements::formRule() (line 177 of /var/www/speel7/sites/all/modules/civicrm/CRM/Admin/Form/WordReplacements.php).
when I enter something and save it. (on CiviCRM 4.01 and Drupal 7)
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Anyone using Word Replacement?
May 12, 2011, 03:52:58 am
Hi,

Using it works fine on 3.3.x.

By default, the item you add is not enabled (not sure what's the logic of having it disabled by default when you add something). Double check it's enabled. Try checking partial match as well if it still doesn't work.

X+

P.S. It works on 99% of the case, but sometimes there is a substitution that is done after the word replacement, so might be why it doesn't catch it?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Anyone using Word Replacement?
May 12, 2011, 04:22:36 am
Erik, fixed.
Quote
Index: CRM/Admin/Form/WordReplacements.php
===================================================================
--- CRM/Admin/Form/WordReplacements.php   (revision 34231)
+++ CRM/Admin/Form/WordReplacements.php   (working copy)
@@ -173,10 +173,11 @@
             if ( $v && !$newValues[$k] ) {
                 $errors['new['.$k.']'] = ts( 'Please Enter the value for Replacement Word' );
             } elseif ( !$v && $newValues[$k] ) {
-                $errors['old['.$k.']'] = ts( 'Please Enter the value for Original Word' );       
-            } elseif ( ( !$newValues[$k] && !$oldValues[$k] ) && ( $enabled[$k] || $exactMatch[$k] ) ) {
-                $errors['old['.$k.']'] = ts( 'Please Enter the value for Original Word' );       
-                $errors['new['.$k.']'] = ts( 'Please Enter the value for Replacement Word' );       
+                $errors['old['.$k.']'] = ts( 'Please Enter the value for Original Word' );
+            } elseif ( ( !CRM_Utils_Array::value( $k, $newValues ) && !CRM_Utils_Array::value( $k, $oldValues ) )
+                    && ( CRM_Utils_Array::value( $k,  $enabled ) || CRM_Utils_Array::value( $k, $exactMatch ) ) ) {
+                $errors['old['.$k.']'] = ts( 'Please Enter the value for Original Word' );     
+                $errors['new['.$k.']'] = ts( 'Please Enter the value for Replacement Word' );   
             }
         }
         
@@ -199,7 +200,7 @@
             if ( CRM_Utils_Array::value( $i, $params['new'] ) &&
                  CRM_Utils_Array::value( $i, $params['old'] ) ) {
                 if ( CRM_Utils_Array::value( $i, $params['enabled'] ) )  {
-                    if ( is_array( $params['cb'] ) && array_key_exists( $i, $params['cb']) ) {
+                    if ( CRM_Utils_Array::value( 'cb', $params ) && is_array( $params['cb'] ) && array_key_exists( $i, $params['cb']) ) {
                         $enabled['exactMatch'] += array($params['old'][$i]=>$params['new'][$i]);
                     } else {
                         $enabled['wildcardMatch'] += array($params['old'][$i]=>$params['new'][$i]);

Found this reply helpful? Support CiviCRM

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Anyone using Word Replacement?
May 12, 2011, 05:22:11 am
Thanks guys!
X, I used it on demo and it worked on 3.4 beta......I will have a further play :-)
« Last Edit: May 12, 2011, 05:28:30 am by Erik Hommel »
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Internationalization and Localization (Moderators: Michał Mach, mathieu) »
  • Anyone using Word Replacement?

This forum was archived on 2017-11-26.