Skip to content

Commit 87df4d3

Browse files
committed
Fix translations and remove config value on upgrade
1 parent 15864bc commit 87df4d3

2 files changed

Lines changed: 50 additions & 20 deletions

File tree

classes/Form/ConfigurationForm.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,89 +66,89 @@ public function generate()
6666
$helper->submit_action = 'submit' . $this->module->name;
6767
$helper->toolbar_btn = [
6868
'save' => [
69-
'desc' => $this->module->trans('Save', [], 'Modules.Googleanalytics.Admin'),
69+
'desc' => $this->module->getTranslator()->trans('Save', [], 'Modules.Googleanalytics.Admin'),
7070
'href' => AdminController::$currentIndex . '&configure=' . $this->module->name . '&save=' . $this->module->name .
7171
'&token=' . $helper->token,
7272
],
7373
'back' => [
7474
'href' => AdminController::$currentIndex . '&token=' . $helper->token,
75-
'desc' => $this->module->trans('Back to list', [], 'Modules.Googleanalytics.Admin'),
75+
'desc' => $this->module->getTranslator()->trans('Back to list', [], 'Modules.Googleanalytics.Admin'),
7676
],
7777
];
7878

7979
$fields_form = [];
8080
// Init Fields form array
8181
$fields_form[0]['form'] = [
8282
'legend' => [
83-
'title' => $this->module->trans('Settings', [], 'Modules.Googleanalytics.Admin'),
83+
'title' => $this->module->getTranslator()->trans('Settings', [], 'Modules.Googleanalytics.Admin'),
8484
],
8585
'input' => [
8686
[
8787
'type' => 'text',
88-
'label' => $this->module->trans('Google Analytics Tracking ID', [], 'Modules.Googleanalytics.Admin'),
88+
'label' => $this->module->getTranslator()->trans('Google Analytics Tracking ID', [], 'Modules.Googleanalytics.Admin'),
8989
'name' => 'GA_ACCOUNT_ID',
9090
'size' => 20,
9191
'required' => true,
92-
'desc' => $this->module->trans('This information is available in your Google Analytics account. Google Analytics 4 tracking ID starts with "G-".', [], 'Modules.Googleanalytics.Admin'),
92+
'desc' => $this->module->getTranslator()->trans('This information is available in your Google Analytics account. Google Analytics 4 tracking ID starts with "G-".', [], 'Modules.Googleanalytics.Admin'),
9393
],
9494
[
9595
'type' => 'switch',
96-
'label' => $this->module->trans('Enable User ID tracking', [], 'Modules.Googleanalytics.Admin'),
96+
'label' => $this->module->getTranslator()->trans('Enable User ID tracking', [], 'Modules.Googleanalytics.Admin'),
9797
'name' => 'GA_USERID_ENABLED',
9898
'values' => [
9999
[
100100
'id' => 'ga_userid_enabled',
101101
'value' => 1,
102-
'label' => $this->module->trans('Yes', [], 'Modules.Googleanalytics.Admin'),
102+
'label' => $this->module->getTranslator()->trans('Yes', [], 'Modules.Googleanalytics.Admin'),
103103
],
104104
[
105105
'id' => 'ga_userid_disabled',
106106
'value' => 0,
107-
'label' => $this->module->trans('No', [], 'Modules.Googleanalytics.Admin'),
107+
'label' => $this->module->getTranslator()->trans('No', [], 'Modules.Googleanalytics.Admin'),
108108
],
109109
],
110110
],
111111
[
112112
'type' => 'switch',
113-
'label' => $this->module->trans('Anonymize IP', [], 'Modules.Googleanalytics.Admin'),
113+
'label' => $this->module->getTranslator()->trans('Anonymize IP', [], 'Modules.Googleanalytics.Admin'),
114114
'name' => 'GA_ANONYMIZE_ENABLED',
115-
'hint' => $this->module->trans('Use this option to anonymize the visitor’s IP to comply with data privacy laws in some countries', [], 'Modules.Googleanalytics.Admin'),
115+
'hint' => $this->module->getTranslator()->trans('Use this option to anonymize the visitor’s IP to comply with data privacy laws in some countries', [], 'Modules.Googleanalytics.Admin'),
116116
'values' => [
117117
[
118118
'id' => 'ga_anonymize_enabled',
119119
'value' => 1,
120-
'label' => $this->module->trans('Yes', [], 'Modules.Googleanalytics.Admin'),
120+
'label' => $this->module->getTranslator()->trans('Yes', [], 'Modules.Googleanalytics.Admin'),
121121
],
122122
[
123123
'id' => 'ga_anonymize_disabled',
124124
'value' => 0,
125-
'label' => $this->module->trans('No', [], 'Modules.Googleanalytics.Admin'),
125+
'label' => $this->module->getTranslator()->trans('No', [], 'Modules.Googleanalytics.Admin'),
126126
],
127127
],
128128
],
129129
[
130130
'type' => 'switch',
131-
'label' => $this->module->trans('Enable Back Office Tracking', [], 'Modules.Googleanalytics.Admin'),
131+
'label' => $this->module->getTranslator()->trans('Enable Back Office Tracking', [], 'Modules.Googleanalytics.Admin'),
132132
'name' => 'GA_TRACK_BACKOFFICE_ENABLED',
133-
'hint' => $this->module->trans('Use this option to enable the tracking inside the Back Office', [], 'Modules.Googleanalytics.Admin'),
133+
'hint' => $this->module->getTranslator()->trans('Use this option to enable the tracking inside the Back Office', [], 'Modules.Googleanalytics.Admin'),
134134
'values' => [
135135
[
136136
'id' => 'ga_track_backoffice',
137137
'value' => 1,
138-
'label' => $this->module->trans('Yes', [], 'Modules.Googleanalytics.Admin'),
138+
'label' => $this->module->getTranslator()->trans('Yes', [], 'Modules.Googleanalytics.Admin'),
139139
],
140140
[
141141
'id' => 'ga_do_not_track_backoffice',
142142
'value' => 0,
143-
'label' => $this->module->trans('No', [], 'Modules.Googleanalytics.Admin'),
143+
'label' => $this->module->getTranslator()->trans('No', [], 'Modules.Googleanalytics.Admin'),
144144
],
145145
],
146146
],
147147
[
148148
'type' => 'select',
149-
'label' => $this->module->trans('Canceled order states', [], 'Modules.Googleanalytics.Admin'),
149+
'label' => $this->module->getTranslator()->trans('Canceled order states', [], 'Modules.Googleanalytics.Admin'),
150150
'name' => 'GA_CANCELLED_STATES',
151-
'desc' => $this->module->trans('Choose order states in which you consider the given order canceled. This will usually be the default "Canceled" state, but some stores may have extra states like "Returned", etc.', [], 'Modules.Googleanalytics.Admin'),
151+
'desc' => $this->module->getTranslator()->trans('Choose order states in which you consider the given order canceled. This will usually be the default "Canceled" state, but some stores may have extra states like "Returned", etc.', [], 'Modules.Googleanalytics.Admin'),
152152
'class' => 'chosen',
153153
'multiple' => true,
154154
'options' => [
@@ -159,7 +159,7 @@ public function generate()
159159
],
160160
],
161161
'submit' => [
162-
'title' => $this->module->trans('Save', [], 'Modules.Googleanalytics.Admin'),
162+
'title' => $this->module->getTranslator()->trans('Save', [], 'Modules.Googleanalytics.Admin'),
163163
],
164164
];
165165

@@ -209,6 +209,6 @@ public function treat()
209209
Configuration::updateValue('GA_CANCELLED_STATES', json_encode($gaCancelledStates));
210210
}
211211

212-
return $this->module->displayConfirmation($this->module->trans('Settings updated successfully.', [], 'Modules.Googleanalytics.Admin'));
212+
return $this->module->displayConfirmation($this->module->getTranslator()->trans('Settings updated successfully.', [], 'Modules.Googleanalytics.Admin'));
213213
}
214214
}

upgrade/upgrade-5.0.0.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* Copyright since 2007 PrestaShop SA and Contributors
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
8+
* that is bundled with this package in the file LICENSE.md.
9+
* It is also available through the world-wide-web at this URL:
10+
* https://opensource.org/licenses/AFL-3.0
11+
* If you did not receive a copy of the license and are unable to
12+
* obtain it through the world-wide-web, please send an email
13+
* to license@prestashop.com so we can send you a copy immediately.
14+
*
15+
* @author PrestaShop SA <contact@prestashop.com>
16+
* @copyright Since 2007 PrestaShop SA and Contributors
17+
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
18+
* International Registered Trademark & Property of PrestaShop SA
19+
*/
20+
if (!defined('_PS_VERSION_')) {
21+
exit;
22+
}
23+
24+
/**
25+
* @param Ps_Googleanalytics $object
26+
*/
27+
function upgrade_module_5_0_0($object)
28+
{
29+
return Configuration::deleteByName('GA_V4_ENABLED');
30+
}

0 commit comments

Comments
 (0)