-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpgrader.php
263 lines (242 loc) · 11.6 KB
/
Upgrader.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<?php
/*
be.chiro.civi.dutch47 - Temporary fix Dutch translation for CiviCRM 4.7.
Copyright (C) 2016 Chirojeugd-Vlaanderen vzw
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Collection of upgrade steps.
*/
class CRM_Dutch47_Upgrader extends CRM_Dutch47_Upgrader_Base {
/**
* An array of translations that we might want to put into Transifex once
* CRM-17737 is fixed.
*
* This is work in progress.
*
* I translate the verbs as infinitives in Dutch. In CiviCRM 4.6 some
* were translated as infinitive, some as imperative, but most as
* infinitive.
* I also put the subject in front of the infinitive, since that seems
* to be more sensible in Dutch.
*
* @var array
*/
protected $translations = array (
// Contact actions
'Add activity' => 'Activiteit toevoegen',
// Organization and household is not translated within the string
// below, but I think that's a bug in Core CiviCRM.
'Add relationship - to %1' => 'Relatie toevoegen - aan %1',
'Communication preferences - alter' => 'Communicatievoorkeuren - wijzigen',
'Delete contacts' => 'Contacten verwijderen',
'Delete permanently' => 'Definitief verwijderen',
'Email - send now (to 50 or less)' => 'E-mail - nu verzenden (naar 50 of minder)',
'Email - unhold addresses' => 'E-mail - adressen vrijgeven',
'Export contacts' => 'Contacten exporteren',
'Group - add contacts' => 'Groep - contacten toevoegen',
// CiviCRM 4.6 translates 'smart group' as 'smart groep', which is certainly
// not correct. Because I don't want to introduce a totally new translation
// (like 'slimme groep'), I will use 'smargroep', which complies to the
// general rules of compounds in Dutch.
'Group - create smart group' => 'Groep - smartgroep maken',
'Group - remove contacts' => 'Groep - contacten verwijderen',
// I think 'verzendetiketten' is a strange word, but it is used as a
// translation in CiviCRM 4.6 as well.
'Mailing labels - print' => 'Verzendetiketten - afdrukken',
'Merge contacts' => 'Contacten samenvoegen',
'PDF letters - print' => 'PDF-brieven - afdrukken',
'Print selected rows' => 'Geselecteerde rijen afdrukken',
'Register participants for event' => 'Deelnemers inschrijven voor evenement',
'Restore contacts from trash' => 'Contacten terughalen uit prullenbak',
// I also think 'kenmerk' is a strange translation, but it was used
// before.
'Tag - add to contacts' => 'Kenmerk - toekennen aan contacten',
'Tag - remove from contacts' => 'Kenmerk - verwijderen van contacten',
'Update multiple contacts' => 'Meerdere contacten bijwerken',
// Search contributions
'Date Received' => 'Ontvangstdatum',
// Translate addresses. The below covers 99% of our contacts ;-)
'BELGIUM' => 'België',
// Participant actions
'Cancel registration' => 'Inschrijving annuleren',
'Delete participants from event' => 'Deelnemers uitschrijven voor evenement',
'Email - send now' => 'E-mail - nu verzenden',
'Export participants' => 'Deelnemers exporteren',
'Name badges - print' => 'Naambadges - afdrukken',
'PDF letter - print for participants' => 'PDF-brief - afdrukken voor deelnemers',
'Participant status - change (emails sent)' => 'Deelnemersstatus - wijzigen (e-mails verzonden)',
'Update multiple participants' => 'Meerdere deelnemers bijwerken',
// Contribution actions
'Export contributions' => 'Bijdragen exporteren',
'Receipts - print or email' => 'Ontvangstbewijzen - afdrukken of mailen',
'Thank-you letters - print or email' => 'Bedankbrieven - afdrukken of mailen',
'Update multiple contributions' => 'Meerdere bijdragen bijwerken',
'Update pending contribution status' => 'Status bijdragen in behandeling bijwerken',
// Membership actions
'Export members' => 'Leden exporteren',
// In our organisation, memberships are translated as 'aansluitingen',
// but we'll stick to the CiviCRM defaults in this extension :-)
'Update multiple memberships' => 'Meerdere lidmaatschappen bijwerken',
);
// Option values to be translated:
protected $option_value_translations = array (
'relative_date_filters' => array(
'This week' => 'Deze week',
// 'Kalendermaand' sounds strange in Dutch.
'This calendar month' => 'Deze maand',
'This quarter' => 'Dit kwartaal',
'This calendar year' => 'Dit kalenderjaar',
'Previous week' => 'Vorige week',
'Previous calendar month' => 'Vorige maand',
'Previous quarter' => 'Vorig kwartaal',
'Previous calendar year' => 'Vorig kalenderjaar',
'Last 7 days including today' => 'Afgelopen 7 dagen, vandaag inbegrepen',
'Last 30 days including today' => 'Afgelopen 30 dagen, vandaag inbegrepen',
'Last 60 days including today' => 'Afgelopen 60 dagen, vandaag inbegrepen',
'Last 90 days including today' => 'Afgelopen 90 dagen, vandaag inbegrepen',
'Last 12 months including today' => 'Afgelopen 12 maanden, vandaag inbegrepen',
'Last 2 years including today' => 'Afgelopen 2 jaar, vandaag inbegrepen',
'Last 3 years including today' => 'Afgelopen 3 jaar, vandaag inbegrepen',
'Next week' => 'Volgende week',
'Next calendar month' => 'Volgende maand',
'Next quarter' => 'Volgend kwartaal',
'Next fiscal year' => 'Volgend fiscaal jaar',
'Next calendar year' => 'Volgend kalenderjaar',
'Next 7 days including today' => 'Komende 7 dagen, vandaag inbegrepen',
'Next 30 days including today' => 'Komende 30 dagen, vandaag inbegrepen',
'Next 60 days including today' => 'Komende 60 dagen, vandaag inbegrepen',
'Next 90 days including today' => 'Komende 90 dagen, vandaag inbegrepen',
'Next 12 months including today' => 'Komende 12 maanden, vandaag inbegrepen',
// I have no clue what the below even mean:
// 'current week to-date', 'current calendar month to-date',
// 'current quarter to-date', 'current calendar year to-date'
// All the below might be wrong; I am tu dumb for this. X-S
'To end of yesterday' => 'Voor vandaag',
'To end of previous week' => 'Voor deze week',
'To end of previous calendar month' => 'Voor deze maand',
'To end of previous quarter' => 'Voor dit kwartaal',
'To end of previous calendar year' => 'Voor dit kalenderjaar',
'From start of current day' => 'Vanaf vandaag',
'From start of current week' => 'Vanaf deze week',
'From start of current calendar month' => 'Vanaf deze maand',
'From start of current quarter' => 'Vanaf dit kwartaal',
'From start of current calendar year' => 'Vanaf dit kalenderjaar',
'To end of current week' => 'Tot eind deze week',
'To end of current calendar month' => 'Tot eind deze maand',
'To end of current quarter' => 'Tot eind dit kwartaal',
'To end of current calendar year' => 'Tot eind dit kalenderjaar',
'Previous 2 days' => 'Vorige 2 dagen',
'Previous 2 weeks' => 'Vorige 2 weken',
'Previous 2 calendar months' => 'Vorige 2 maanden',
'Previous 2 quarters' => 'Vorige half jaar',
'Previous 2 calendar years' => 'Vorige 2 kalenderjaren',
'Day prior to yesterday' => 'Eergisteren',
'Week prior to previous week' => 'Week voor vorige week',
'Month prior to previous calendar month' => 'Maand voor vorige maand',
'Quarter prior to previous quarter' => 'Kwartaal voor vorig kwartaal',
'Year prior to previous calendar year' => 'Jaar voor vorig kalenderjaar',
'From end of previous week' => 'Vanaf deze week',
'From end of previous calendar month' => 'Vanaf deze maand',
'From end of previous quarter' => 'Vanaf dit kwartaal',
'From end of previous calendar year' => 'Vanaf dit jaar',
));
/**
* Installs word replacements.
*/
public function enable() {
$result = TRUE;
// word replacement translations
foreach ($this->translations as $key => $value) {
// Only replace words if there are no existing replacements
$get_result = civicrm_api3('WordReplacement', 'get', array(
'find_word' => $key,
));
$result &= !$get_result['is_error'];
if (!$get_result['is_error'] && $get_result['count'] == 0) {
$create_result = civicrm_api3('WordReplacement', 'create', array(
'find_word' => $key,
'replace_word' => $value,
'is_active' => 1,
'match_type' => 'wildcardMatch',
// I assume there is only one, unique domain.
'domain_id' => 1,
));
$result &= !$create_result['is_error'];
}
}
foreach ($this->option_value_translations as $option_group_name => $translations) {
$option_group_result = civicrm_api3('OptionGroup', 'get', array(
'name' => $option_group_name
));
if (!$option_group_result['is_error'] && $option_group_result['count'] == 1) {
$option_group_id = $option_group_result['id'];
$result &= $this->translateOptionValues($option_group_id, $translations);
}
}
return $result;
}
/**
* Translates the labels of option values.
*
* @param int $option_group_id option group of which the labels should be translated.
* @param array $translations key-value array with translations (src => dst)
* @return bool TRUE if the CiviCRM API didn't return an error.
*/
protected function translateOptionValues($option_group_id, $translations) {
if (!is_int($option_group_id)) {
die('$option_group_id should be an integer.');
}
if (!is_array($translations)) {
die('$translations should be an array.');
}
foreach ($translations as $key => $value) {
$update_result = civicrm_api3('OptionValue', 'get', array(
'option_group_id' => $option_group_id,
'label' => $key,
'api.OptionValue.create' => array(
'id' => '$value.id',
'label' => $value,
)
));
$result &= !$update_result['is_error'];
}
return $result;
}
/**
* Removes the translations that have not been changed.
*/
public function disable() {
$result = TRUE;
// remove unchanged word replacements.
foreach ($this->translations as $key => $value) {
$delete_result = civicrm_api3('WordReplacement', 'get', array(
'find_word' => $key,
'replace_word' => $value,
'api.WordReplacement.delete' => array('id' => '$value.id'),
));
$result &= !$delete_result['is_error'];
}
// Revert unchanged option values for relative_date_filters
foreach ($this->option_value_translations as $option_group_name => $translations) {
$option_group_result = civicrm_api3('OptionGroup', 'get', array(
'name' => $option_group_name
));
if (!$option_group_result['is_error'] && $option_group_result['count'] == 1) {
$option_group_id = $option_group_result['id'];
// Translate the other way round.
$result &= $this->translateOptionValues($option_group_id, array_flip($translations));
}
}
return $result;
}
}