From b1e1835653715067da565f6ec8af3c23541fe83f Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 1 Mar 2015 21:19:03 -0500 Subject: [PATCH] CRM-15932 - Fix untranslated strings & localize dates --- CRM/Campaign/Page/DashBoard.php | 2 +- CRM/Core/Form/RecurringEntity.php | 88 +++++++++---------- CRM/Core/Page/RecurringEntityPreview.php | 4 +- CRM/Event/Form/ManageEvent.php | 1 + CRM/Event/Form/ManageEvent/Repeat.php | 1 - templates/CRM/Core/Form/RecurringEntity.hlp | 21 +---- templates/CRM/Core/Form/RecurringEntity.tpl | 35 +++----- .../Form/ManageEvent/ConfirmRepeatMode.tpl | 24 ++--- .../CRM/Event/Form/ManageEvent/Repeat.tpl | 7 +- 9 files changed, 75 insertions(+), 108 deletions(-) diff --git a/CRM/Campaign/Page/DashBoard.php b/CRM/Campaign/Page/DashBoard.php index 73a7c852f5..f51bdfc4e0 100644 --- a/CRM/Campaign/Page/DashBoard.php +++ b/CRM/Campaign/Page/DashBoard.php @@ -314,7 +314,7 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { $surveysData[$sid]['campaign'] = CRM_Utils_Array::value($campaignId, $campaigns); $surveysData[$sid]['activity_type'] = $surveyType[$survey['activity_type_id']]; if (!empty($survey['release_frequency'])) { - $surveysData[$sid]['release_frequency'] = $survey['release_frequency'] . ' Day(s)'; + $surveysData[$sid]['release_frequency'] = $survey['release_frequency'] . ' ' . ts('Day(s)'); } $action = array_sum(array_keys(self::surveyActionLinks($surveysData[$sid]['activity_type']))); diff --git a/CRM/Core/Form/RecurringEntity.php b/CRM/Core/Form/RecurringEntity.php index 8dc259190e..de26da8a7d 100644 --- a/CRM/Core/Form/RecurringEntity.php +++ b/CRM/Core/Form/RecurringEntity.php @@ -96,16 +96,23 @@ class CRM_Core_Form_RecurringEntity { self::$_scheduleReminderID = self::$_scheduleReminderDetails->id; } } - if ($entityTable) { - CRM_Core_OptionValue::getValues(array('name' => $entityTable . '_repeat_exclude_dates_' . self::$_parentEntityId), $optionValue); - $excludeOptionValues = array(); - if (!empty($optionValue)) { - foreach ($optionValue as $key => $val) { - $excludeOptionValues[$val['value']] = CRM_Utils_Date::customFormat($val['value']); - } - self::$_excludeDateInfo = $excludeOptionValues; + CRM_Core_OptionValue::getValues(array('name' => $entityTable . '_repeat_exclude_dates_' . self::$_parentEntityId), $optionValue); + $excludeOptionValues = array(); + if (!empty($optionValue)) { + foreach ($optionValue as $key => $val) { + $excludeOptionValues[$val['value']] = CRM_Utils_Date::customFormat($val['value']); } + self::$_excludeDateInfo = $excludeOptionValues; } + + // Assign variables + $entityType = CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getClassForTable($entityTable)); + $tpl = CRM_Core_Smarty::singleton(); + $tpl->assign('recurringEntityType', ts($entityType)); + $tpl->assign('currentEntityId', self::$_entityId); + $tpl->assign('entityTable', self::$_entityTable); + $tpl->assign('scheduleReminderId', self::$_scheduleReminderID); + $tpl->assign('hasParent', self::$_hasParent); } /** @@ -159,63 +166,49 @@ class CRM_Core_Form_RecurringEntity { * @param CRM_Core_Form $form */ public static function buildQuickForm(&$form) { - if (self::$_entityTable) { - $entityType = explode("_", self::$_entityTable); - if ($entityType[1]) { - $form->assign('entityType', ucwords($entityType[1])); - } - } - $form->assign('currentEntityId', self::$_entityId); - $form->assign('entityTable', self::$_entityTable); - $form->assign('scheduleReminderId', self::$_scheduleReminderID); - $form->assign('hasParent', self::$_hasParent); - $form->_freqUnits = array('hour' => 'hour') + CRM_Core_OptionGroup::values('recur_frequency_units'); - foreach ($form->_freqUnits as $val => $label) { - if ($label == "day") { - $label = "dai"; - } - $freqUnitsDisplay[$val] = ts('%1ly', array(1 => $label)); - } - // echo "
";print_r($freqUnitsDisplay);
+    $freqUnitsDisplay = array('hour' => ts('hour')) + CRM_Core_OptionGroup::values('recur_frequency_units');
+
+    // For some reason this is using the following as keys rather than the standard numeric keys returned by CRM_Utils_Date
     $dayOfTheWeek = array(
-      'monday' => 'Monday',
-      'tuesday' => 'Tuesday',
-      'wednesday' => 'Wednesday',
-      'thursday' => 'Thursday',
-      'friday' => 'Friday',
-      'saturday' => 'Saturday',
-      'sunday' => 'Sunday',
+      'sunday',
+      'monday',
+      'tuesday',
+      'wednesday',
+      'thursday',
+      'friday',
+      'saturday',
     );
-    $form->add('select', 'repetition_frequency_unit', ts('Repeats:'), $freqUnitsDisplay);
+    $dayOfTheWeek = array_combine($dayOfTheWeek, CRM_Utils_Date::getAbbrWeekdayNames());
+    $form->add('select', 'repetition_frequency_unit', ts('Repeats every'), $freqUnitsDisplay);
     $numericOptions = CRM_Core_SelectValues::getNumericOptions(1, 30);
-    $form->add('select', 'repetition_frequency_interval', ts('Repeats every:'), $numericOptions, '', array('style' => 'width:55px;'));
+    $form->add('select', 'repetition_frequency_interval', NULL, $numericOptions);
     $form->addDateTime('repetition_start_date', ts('Repetition Start Date'), FALSE, array('formatType' => 'activityDateTime'));
     foreach ($dayOfTheWeek as $key => $val) {
-      $startActionCondition[] = $form->createElement('checkbox', $key, NULL, substr($val . " ", 0, 3));
+      $startActionCondition[] = $form->createElement('checkbox', $key, NULL, $val);
     }
     $form->addGroup($startActionCondition, 'start_action_condition', ts('Repeats on'));
     $roptionTypes = array(
       '1' => ts('day of the month'),
       '2' => ts('day of the week'),
     );
-    $form->addRadio('repeats_by', ts("Repeats By:"), $roptionTypes, array(), NULL);
+    $form->addRadio('repeats_by', ts("Repeats By"), $roptionTypes, array(), NULL);
     $getMonths = CRM_Core_SelectValues::getNumericOptions(1, 31);
-    $form->add('select', 'limit_to', '', $getMonths, FALSE, array('style' => 'width:55px;'));
+    $form->add('select', 'limit_to', '', $getMonths);
     $dayOfTheWeekNo = array(
-      'first' => 'First',
-      'second' => 'Second',
-      'third' => 'Third',
-      'fourth' => 'Fourth',
-      'last' => 'Last',
+      'first' => ts('First'),
+      'second' => ts('Second'),
+      'third' => ts('Third'),
+      'fourth' => ts('Fourth'),
+      'last' => ts('Last'),
     );
-    $form->add('select', 'entity_status_1', ts(''), $dayOfTheWeekNo);
-    $form->add('select', 'entity_status_2', ts(''), $dayOfTheWeek);
+    $form->add('select', 'entity_status_1', '', $dayOfTheWeekNo);
+    $form->add('select', 'entity_status_2', '', $dayOfTheWeek);
     $eoptionTypes = array(
       '1' => ts('After'),
       '2' => ts('On'),
     );
-    $form->addRadio('ends', ts("Ends:"), $eoptionTypes, array(), NULL);
+    $form->addRadio('ends', ts("Ends"), $eoptionTypes, array(), NULL);
     $form->add('text', 'start_action_offset', ts(''), array('size' => 3, 'maxlength' => 2));
     $form->addFormRule(array('CRM_Core_Form_RecurringEntity', 'formRule'));
     $form->addDate('repeat_absolute_date', ts('On'), FALSE, array('formatType' => 'mailing'));
@@ -400,7 +393,6 @@ class CRM_Core_Form_RecurringEntity {
         }
 
         //Set type for API
-        $apiEntityType = array();
         $apiEntityType = explode("_", $type);
         if (!empty($apiEntityType[1])) {
           $apiType = $apiEntityType[1];
@@ -480,7 +472,7 @@ class CRM_Core_Form_RecurringEntity {
           $recursion->linkedEntities = $linkedEntities;
         }
 
-        $recurResult = $recursion->generate();
+        $recursion->generate();
 
         $status = ts('Repeat Configuration has been saved');
         CRM_Core_Session::setStatus($status, ts('Saved'), 'success');
diff --git a/CRM/Core/Page/RecurringEntityPreview.php b/CRM/Core/Page/RecurringEntityPreview.php
index 16cdcecda1..7c6c4b5a28 100644
--- a/CRM/Core/Page/RecurringEntityPreview.php
+++ b/CRM/Core/Page/RecurringEntityPreview.php
@@ -80,10 +80,10 @@ class CRM_Core_Page_RecurringEntityPreview extends CRM_Core_Page {
 
       foreach ($dates as $key => &$value) {
         if ($startDateColumnName) {
-          $value['start_date'] = date('M d, Y h:i:s A \o\n l', strtotime($value[$startDateColumnName]));
+          $value['start_date'] = CRM_Utils_Date::customFormat($value[$startDateColumnName]);
         }
         if ($endDateColumnName && !empty($value[$endDateColumnName])) {
-          $value['end_date'] = date('M d, Y h:i:s A \o\n l', strtotime($value[$endDateColumnName]));
+          $value['end_date'] = CRM_Utils_Date::customFormat($value[$endDateColumnName]);
           $endDates = TRUE;
         }
       }
diff --git a/CRM/Event/Form/ManageEvent.php b/CRM/Event/Form/ManageEvent.php
index 71e00a3981..035b0b488d 100644
--- a/CRM/Event/Form/ManageEvent.php
+++ b/CRM/Event/Form/ManageEvent.php
@@ -97,6 +97,7 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form {
     if (in_array('CiviEvent', $config->enableComponents)) {
       $this->assign('CiviEvent', TRUE);
     }
+    CRM_Core_Form_RecurringEntity::preProcess('civicrm_event');
 
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST');
 
diff --git a/CRM/Event/Form/ManageEvent/Repeat.php b/CRM/Event/Form/ManageEvent/Repeat.php
index 8a4bc05480..c6d4f57f91 100644
--- a/CRM/Event/Form/ManageEvent/Repeat.php
+++ b/CRM/Event/Form/ManageEvent/Repeat.php
@@ -25,7 +25,6 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
 
   public function preProcess() {
     parent::preProcess();
-    CRM_Core_Form_RecurringEntity::preProcess('civicrm_event');
     $this->assign('currentEventId', $this->_id);
 
     $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($this->_id, 'civicrm_event');
diff --git a/templates/CRM/Core/Form/RecurringEntity.hlp b/templates/CRM/Core/Form/RecurringEntity.hlp
index dd1e55571b..476c65946b 100644
--- a/templates/CRM/Core/Form/RecurringEntity.hlp
+++ b/templates/CRM/Core/Form/RecurringEntity.hlp
@@ -29,23 +29,8 @@
   {ts}Repeats{/ts}
 {/htxt}
 {htxt id="id-repeats"}
-  {ts 1=$entityType}Access the drop-down menu here to select how frequently your %1 occurs. Options are:{/ts}
-  
-  {ts 1=$entityType}Example: You would select option "monthly", if your %1 occurs every month.{/ts}
-{/htxt}
-
-{htxt id="id-repeats-every-title"}
-  {ts}Repeats every{/ts}
-{/htxt}
-{htxt id="id-repeats-every"}
-  {ts}This option decides the repetition interval.{/ts}
- {ts 1=$entityType}Example: If your %1 repeats every 5 months, then you would select option 5.{/ts} + {ts 1=$entityType}Access the drop-down menus here to select how frequently your %1 occurs.{/ts} + {ts 1=$entityType}Example: You would select options "1 month", if your %1 occurs every month.{/ts} {/htxt} {htxt id="id-repeats-on-title"} @@ -76,7 +61,7 @@ {/htxt} {htxt id="id-ends-after"} {ts 1=$entityType}Use this field to limit/end the repetition of the %1.{/ts}
- {ts 1=$entityType}Example: If you want to repeat an %1 for six months (i.e it repeats 6 times), then set 6 as a value for this field.{/ts} + {ts 1=$entityType}Example: If you want to repeat an %1 6 times, then set 6 as a value for this field.{/ts} {/htxt} {htxt id="id-ends-on-title"} diff --git a/templates/CRM/Core/Form/RecurringEntity.tpl b/templates/CRM/Core/Form/RecurringEntity.tpl index 35cb50eafd..d1580a003e 100644 --- a/templates/CRM/Core/Form/RecurringEntity.tpl +++ b/templates/CRM/Core/Form/RecurringEntity.tpl @@ -26,7 +26,7 @@
- Repeat {if $entityType}{$entityType}{/if} + {ts 1=$recurringEntityType}Repeat %1{/ts}
@@ -37,44 +37,39 @@ {$form.repetition_start_date.label} {include file="CRM/common/jcalendar.tpl" elementName=repetition_start_date} - - {$form.repetition_frequency_unit.label} * {help id="id-repeats" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"} - {$form.repetition_frequency_unit.html} - - - {$form.repetition_frequency_interval.label} * {help id="id-repeats-every" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"} - {$form.repetition_frequency_interval.html}  hour(s) - + + {$form.repetition_frequency_unit.label} * {help id="id-repeats" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"} + {$form.repetition_frequency_interval.html} {$form.repetition_frequency_unit.html} - + {$form.start_action_condition.html} - {$form.repeats_by.label} - {$form.repeats_by.1.html}  {$form.limit_to.html} {help id="id-repeats-by-month" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"} + {$form.repeats_by.label} {help id="id-repeats-by-month" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"} + {$form.repeats_by.1.html}  {$form.limit_to.html} - {help id="id-repeats-by-week" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"} + {help id="id-repeats-by-week" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"} {$form.repeats_by.2.html}  {$form.entity_status_1.html}  {$form.entity_status_2.html} - {$form.ends.label} * {help id="id-ends-after" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"} - {$form.ends.1.html} {$form.start_action_offset.html} occurrences  + {$form.ends.label} * {help id="id-ends-after" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"} + {$form.ends.1.html} {$form.start_action_offset.html} {ts}occurrences{/ts} - {help id="id-ends-on" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"} + {help id="id-ends-on" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"} {$form.ends.2.html} {include file="CRM/common/jcalendar.tpl" elementName=repeat_absolute_date} - {$form.exclude_date_list.label} {help id="id-exclude-date" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"} + {$form.exclude_date_list.label} {help id="id-exclude-date" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"} {$form.exclude_date_list.html} @@ -104,7 +99,6 @@ $('.crm-core-form-recurringentity-block-repeats_by td').hide(); break; } - $("#repeats-every-text").html($('#repetition_frequency_unit').val()+'(s)'); /***********On Load Set Ends Value (Edit Mode) **********/ switch ($('input:radio[name=ends]:checked').val()) { @@ -141,29 +135,24 @@ $('#repetition_frequency_unit').change(function () { switch ($(this).val()) { case 'hour': - $('#repeats-every-text').html($(this).val()+'(s)'); $('.crm-core-form-recurringentity-block-start_action_condition').hide(); $('.crm-core-form-recurringentity-block-repeats_by td').hide(); break; case 'day': - $('#repeats-every-text').html($(this).val()+'(s)'); $('.crm-core-form-recurringentity-block-start_action_condition').hide(); $('.crm-core-form-recurringentity-block-repeats_by td').hide(); break; case 'week': - $('#repeats-every-text').html($(this).val()+'(s)'); //Show "Repeats On" block when week is selected $('.crm-core-form-recurringentity-block-start_action_condition').show(); $('.crm-core-form-recurringentity-block-repeats_by td').hide(); break; case 'month': - $('#repeats-every-text').html($(this).val()+'(s)'); $('.crm-core-form-recurringentity-block-start_action_condition').hide(); //Show "Repeats By" block when month is selected $('.crm-core-form-recurringentity-block-repeats_by td').show(); break; case 'year': - $('#repeats-every-text').html($(this).val()+'(s)'); $('.crm-core-form-recurringentity-block-start_action_condition').hide(); $('.crm-core-form-recurringentity-block-repeats_by td').hide(); break; diff --git a/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl b/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl index b20a7e1cc7..9f43bdaddd 100644 --- a/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl +++ b/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl @@ -24,23 +24,24 @@ +--------------------------------------------------------------------+ *} {if $hasParent || $isRepeatingEntity || $scheduleReminderId} + {capture assign='entity_type'}{$recurringEntityType|lower}{/capture} {literal} @@ -60,6 +61,7 @@ function cascadeChangesDialog() { CRM.confirm({ + title: "{/literal}{ts escape='js' 1=$entity_type}Update recurring %1{/ts}{literal}", message: $('#recurring-dialog-tpl').html() }) .on('crmConfirm:yes', updateMode) @@ -93,7 +95,7 @@ if (result.status != "" && result.status == 'Done') { $form.submit(); } else if (result.status != "" && result.status == 'Error') { - if (confirm(ts("Mode could not be updated, save only this event?"))) { + if (confirm("{/literal}{ts escape='js' 1=$entity_type}Mode could not be updated, save only this %1?{/ts}{literal}")) { $form.submit(); } } diff --git a/templates/CRM/Event/Form/ManageEvent/Repeat.tpl b/templates/CRM/Event/Form/ManageEvent/Repeat.tpl index 572528dd22..8cd3c500a9 100644 --- a/templates/CRM/Event/Form/ManageEvent/Repeat.tpl +++ b/templates/CRM/Event/Form/ManageEvent/Repeat.tpl @@ -26,7 +26,7 @@
{include file="CRM/Core/Form/RecurringEntity.tpl"} {if $rows} -
+
{ts}Connected Repeating Events{/ts}
{strip} @@ -51,7 +51,7 @@ {else} {assign var="highlight" value=""} {/if} - + {$row.title}  ({ts}ID:{/ts} {$row.id}) @@ -63,7 +63,7 @@ {if $row.is_active eq 1}{ts}Yes{/ts} {else} {ts}No{/ts} {/if} - Manage Event + {ts}Settings{/ts} {$row.start_date|crmDate} {$row.end_date|crmDate} @@ -71,7 +71,6 @@ {/if} {/foreach} - {include file="CRM/common/pager.tpl" location="bottom"} {/strip}
-- 2.25.1