Completed
Push — master ( 1a9778...51fa25 )
by Sander
06:35 queued 03:45
created

TranslationController::getLanguageStrings()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 325
Code Lines 243

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 242
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 243
c 3
b 0
f 0
nc 1
nop 0
dl 0
loc 325
ccs 242
cts 242
cp 1
crap 1
rs 8.2857

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * Nextcloud - passman
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Sander Brand <[email protected]>
9
 * @copyright Sander Brand 2016
10
 */
11
12
namespace OCA\Passman\Controller;
13
14
use OCP\IRequest;
15
use OCP\AppFramework\Http\JSONResponse;
16
use OCP\AppFramework\ApiController;
17
use OCP\IL10N;
18
19
class TranslationController extends ApiController {
20
	private $trans;
21
22
	public function __construct($AppName,
23
								IRequest $request,
24
								IL10N $trans
25
	) {
26
		parent::__construct(
27
			$AppName,
28
			$request,
29
			'GET, POST, DELETE, PUT, PATCH, OPTIONS',
30
			'Authorization, Content-Type, Accept',
31
			86400);
32
		$this->trans = $trans;
33
	}
34
35
36
	/**
37
	 * @NoAdminRequired
38
	 * @NoCSRFRequired
39
	 * @PublicPage
40
	 */
41 1
	public function getLanguageStrings() {
42
		$translations = array(
43
			// js/app/controllers/bookmarklet.js
44 1
			'generating.sharing.keys' =>  $this->trans->t('Generating sharing keys ( %step / 2)'),
45 1
			'invalid.vault.key' => $this->trans->t('Incorrect vault password!'),
46 1
			'password.do.not.match' => $this->trans->t('Passwords do not match'),
47 1
			'general' => $this->trans->t('General'),
48 1
			'custom.fields' => $this->trans->t('Custom Fields'),
49 1
			'error.no.label' => $this->trans->t('Please fill in a label!'),
50 1
			'error.no.value' => $this->trans->t('Please fill in a value!'),
51 1
			'error.loading.file' => $this->trans->t('Error loading file'),
52
53
			// js/app/controllers/credential.js
54 1
			'error.decrypt' => $this->trans->t('An error happened during decryption'),
55 1
			'credential.created' => $this->trans->t('Credential created!'),
56 1
			'credential.deleted' => $this->trans->t('Credential deleted'),
57 1
			'credential.updated' => $this->trans->t('Credential updated'),
58 1
			'credential.recovered' => $this->trans->t('Credential recovered'),
59 1
			'credential.destroyed' => $this->trans->t('Credential destroyed'),
60 1
			'error.loading.file.perm' => $this->trans->t('Error downloading file, you probably don\'t have enough permissions'),
61
62
			// js/app/controllers/edit_credential.js
63 1
			'invalid.qr' => $this->trans->t('Invalid QR code'),
64
65
			// js/app/controllers/export.js
66 1
			'export.starting' => $this->trans->t('Starting export'),
67 1
			'export.decrypt' => $this->trans->t('Decrypting credentials'),
68 1
			'done' => $this->trans->t('Done'),
69
70
			// js/app/controllers/import.js
71 1
			'import.file.read' => $this->trans->t('File read successfully!'),
72
73 1
			'import.no.label' => $this->trans->t('Credential has no label, skipping'),
74 1
			'import.adding' => $this->trans->t('Adding {{credential}}'),
75 1
			'import.added' => $this->trans->t('Added {{credential}}'),
76 1
			'import.loaded' => $this->trans->t('Parsed {{num}} credentials, starting to import'),
77
78
			// js/app/controllers/revision.js
79 1
			'revision.deleted' => $this->trans->t('Revision deleted'),
80 1
			'revision.restored' => $this->trans->t('Revision restored'),
81
82
			// js/app/controllers/settings.js
83 1
			'bookmarklet.text' => $this->trans->t('Save in passman'),
84 1
			'settings.saved' => $this->trans->t('Settings saved'),
85 1
			'settings.general' => $this->trans->t('General settings'),
86 1
			'settings.audit' => $this->trans->t('Password Audit'),
87 1
			'settings.password' => $this->trans->t('Password settings'),
88 1
			'settings.import' => $this->trans->t('Import credentials'),
89 1
			'settings.export' => $this->trans->t('Export credentials'),
90 1
			'settings.sharing' => $this->trans->t('Sharing'),
91 1
			'changepw.navigate.away.warning' => $this->trans->t('Are you sure you want to leave? This WILL corrupt all your credentials'),
92 1
			'incorrect.password' => $this->trans->t('Your old password is incorrect!'),
93 1
			'password.no.match' => $this->trans->t('New passwords do not match!'),
94 1
			'login.new.pass' => $this->trans->t('Please login with your new vault password'),
95
96
			// js/app/controllers/share.js
97 1
			'share.u.g' => $this->trans->t('Share with users and groups'),
98 1
			'share.link' => $this->trans->t('Share link'),
99 1
			'share.navigate.away.warning' => $this->trans->t('Are you sure you want to leave? This will corrupt this credential'),
100 1
			'credential.unshared' => $this->trans->t('Credential unshared'),
101 1
			'credential.shared' => $this->trans->t('Credential shared'),
102 1
			'saved' => $this->trans->t('Saved!'),
103
104
			// js/app/controllers/vault.js
105 1
			'password.poor' => $this->trans->t('Poor'),
106 1
			'password.weak' => $this->trans->t('Weak'),
107 1
			'password.good' => $this->trans->t('Good'),
108 1
			'password.strong' => $this->trans->t('Strong'),
109
			// js/app/directives/credentialfield.js
110 1
			'toggle.visibility' => $this->trans->t('Toggle visibility'),
111 1
			'copy.field' => $this->trans->t('Copy to clipboard'),
112 1
			'copied' => $this->trans->t('Copied to clipboard!'),
113
114
			// js/app/directives/passwordgen.js
115 1
			'password.gen' => $this->trans->t('Generate password'),
116 1
			'password.copy' => $this->trans->t('Copy password to clipboard'),
117 1
			'password.copied' => $this->trans->t('Password copied to clipboard!'),
118
119
			// js/app/directives/progressbar.js
120 1
			'complete' => $this->trans->t('Complete'),
121
122
123
			// templates/views/partials/edit_credential/basics.html
124 1
			'username' => $this->trans->t('Username'),
125 1
			'password.r' => $this->trans->t('Repeat password'),
126 1
			'add.tag' => $this->trans->t('Add Tag'),
127
128
			// templates/views/partials/edit_credential/custom_fields.html
129 1
			'field.label' => $this->trans->t('Field label'),
130 1
			'field.value' => $this->trans->t('Field value'),
131 1
			'select.file' => $this->trans->t('Choose a file'),
132 1
			'text' => $this->trans->t('Text'),
133 1
			'file' => $this->trans->t('File'),
134 1
			'add' => $this->trans->t('Add'),
135 1
			'value' => $this->trans->t('Value'),
136 1
			'type' => $this->trans->t('Type'),
137 1
			'actions' => $this->trans->t('Actions'),
138 1
			'empty' => $this->trans->t('Empty'),
139
140
			// templates/views/partials/edit_credential/files.html
141 1
			'file.name' => $this->trans->t('Filename'),
142 1
			'upload.date' => $this->trans->t('Upload date'),
143 1
			'size' => $this->trans->t('Size'),
144
145
146
			// templates/views/partials/edit_credential/otp.html
147 1
			'upload.qr' => $this->trans->t('Upload your OTP qr code'),
148 1
			'current.qr' => $this->trans->t('Current OTP settings'),
149 1
			'issuer' => $this->trans->t('Issuer'),
150 1
			'secret' => $this->trans->t('Secret'),
151
152
153
			// templates/views/partials/edit_credential/password.html
154 1
			'expire.date' => $this->trans->t('Expire date'),
155 1
			'no.expire.date' => $this->trans->t('No expire date set'),
156 1
			'renew.interval' => $this->trans->t('Renew interval'),
157 1
			'disabled' => $this->trans->t('Disabled'),
158 1
			'days' => $this->trans->t('Day(s)'),
159 1
			'weeks' => $this->trans->t('Week(s)'),
160 1
			'months' => $this->trans->t('Month(s)'),
161 1
			'years' => $this->trans->t('Year(s)'),
162 1
			'generation.settings' => $this->trans->t('Password generation settings'),
163 1
			'password.generation.length' => $this->trans->t('Password length'),
164 1
			'password.generation.min_digits' => $this->trans->t('Minimum amount of digits'),
165 1
			'password.generation.uppercase' => $this->trans->t('Use uppercase letters'),
166 1
			'password.generation.lowercase' => $this->trans->t('Use lowercase letters'),
167 1
			'password.generation.digits' => $this->trans->t('Use numbers'),
168 1
			'password.generation.special' => $this->trans->t('Use special characters'),
169 1
			'password.generation.ambiguous' => $this->trans->t('Avoid ambiguous characters'),
170 1
			'password.generation.require_same' => $this->trans->t('Require every character type'),
171
172
173
			// templates/views/partials/forms/settings/export.html
174 1
			'export.type' => $this->trans->t('Export type'),
175 1
			'export' => $this->trans->t('Export'),
176
177
			// templates/views/partials/forms/settings/general_settings.html
178 1
			'rename.vault' => $this->trans->t('Rename vault'),
179 1
			'rename.vault.name' => $this->trans->t('New vault name'),
180 1
			'change' => $this->trans->t('Change'),
181 1
			'change.vault.key' => $this->trans->t('Change vault key'),
182 1
			'old.vault.password' => $this->trans->t('Old vault password'),
183 1
			'new.vault.password' => $this->trans->t('New vault password'),
184 1
			'new.vault.pw.r' => $this->trans->t('New vault password repeat'),
185 1
			'warning.leave' => $this->trans->t('Please wait your vault is being updated, do not leave this page.'),
186 1
			'processing' => $this->trans->t('Processing'),
187 1
			'total.progress' => $this->trans->t('Total progress'),
188 1
			'about.passman' => $this->trans->t('About Passman'),
189 1
			'version' => $this->trans->t('Version'),
190 1
			'donate.support' => $this->trans->t('Donate to support development'),
191 1
			'bookmarklet' => $this->trans->t('Bookmarklet'),
192 1
			'bookmarklet.info1' => $this->trans->t('Save your passwords with 1 click!'),
193 1
			'bookmarklet.info2' => $this->trans->t('Drag below button to your bookmark toolbar.'),
194 1
			'delete.vault' => $this->trans->t('Delete vault'),
195 1
			'vault.password' => $this->trans->t('Vault password'),
196 1
			'vault.remove.notice' => $this->trans->t('This process is irreversible'),
197 1
			'delete.vault.checkbox' => $this->trans->t('Delete my precious passwords'),
198 1
			'deleting.pw' => $this->trans->t('Deleting {{password}}...'),
199 1
			'delete.vault.confirm' => $this->trans->t('Yes, delete my precious passwords'),
200
201
202
			// templates/views/partials/forms/settings/import.html
203 1
			'import.type' => $this->trans->t('Import type'),
204 1
			'import' => $this->trans->t('Import'),
205 1
			'read.progress' => $this->trans->t('Read progress'),
206 1
			'upload.progress' => $this->trans->t('Upload progress'),
207
208
			// templates/views/partials/forms/settings/password_settings.html
209
			// inherent from other pages
210
211
			// templates/views/partials/forms/settings/sharing.html
212 1
			'priv.key' => $this->trans->t('Private Key'),
213 1
			'pub.key' => $this->trans->t('Public key'),
214 1
			'key.size' => $this->trans->t('Key size'),
215 1
			'save.keys' => $this->trans->t('Save keys'),
216 1
			'gen.keys' => $this->trans->t('Generate sharing keys'),
217 1
			'generating.keys' => $this->trans->t('Generating sharing keys'),
218
219
			// templates/views/partials/forms/settings/tool.html
220 1
			'tool.intro' => $this->trans->t('The password tool will scan your password, calculate the avarage crack time and, if below the threshold, show them'),
221 1
			'min.strength' => $this->trans->t('Minimum password stength'),
222 1
			'scan.result.msg' => $this->trans->t('Passman scanned your passwords, and here is the result.'),
223 1
			'scan.result' => $this->trans->t('A total of {{scan_result}} weak credentials.'),
224 1
			'score' => $this->trans->t('Score'),
225 1
			'action' => $this->trans->t('Action'),
226
227
			// templates/vieuws/partials/forms/share_credential/basics.html
228 1
			'search.u.g' => $this->trans->t('Search users or groups...'),
229 1
			'cyphering' => $this->trans->t('Cyphering'),
230 1
			'uploading' => $this->trans->t('Uploading'),
231 1
			'user' => $this->trans->t('User'),
232 1
			'crypto.time' => $this->trans->t('Crypto time'),
233 1
			'crypto.total.time' => $this->trans->t('Total time spent cyphering'),
234 1
			'perm.read' => $this->trans->t('Read'),
235 1
			'perm.write' => $this->trans->t('Write'),
236 1
			'perm.files' => $this->trans->t('Files'),
237 1
			'perm.revisions' => $this->trans->t('Revisions'),
238 1
			'pending' => $this->trans->t('Pending'),
239
240
241
			// templates/vieuws/partials/forms/share_credential/link_sharing.html
242 1
			'enable.link.sharing' => $this->trans->t('Enable link sharing'),
243 1
			'share.until.date' => $this->trans->t('Share until date'),
244 1
			'expire.views' => $this->trans->t('Expire after views'),
245 1
			'click.share' => $this->trans->t('Click share first'),
246 1
			'show.files' => $this->trans->t('Show files'),
247
248
249
			// templates/views/partials/password-meter.html
250 1
			'details' => $this->trans->t('Details'),
251 1
			'hide.details' => $this->trans->t('Hide details'),
252 1
			'password.score' => $this->trans->t('Password score'),
253 1
			'cracking.times' => $this->trans->t('Cracking times'),
254 1
			'cracking.time.100h' => $this->trans->t('100 / hour'),
255 1
			'cracking.time.100h.desc' => $this->trans->t('Throttled online attack'),
256 1
			'cracking.time.10s' => $this->trans->t('10 / second'),
257 1
			'cracking.time.10s.desc' => $this->trans->t('Unthrottled online attack'),
258 1
			'cracking.time.10ks' => $this->trans->t('10k / second'),
259 1
			'cracking.time.10ks.desc' => $this->trans->t('Offline attack, slow hash, many cores'),
260 1
			'cracking.time.10Bs' => $this->trans->t('10B / second'),
261 1
			'cracking.time.10Bs.desc' => $this->trans->t('Offline attack, fast hash, many cores'),
262 1
			'match.sequence' => $this->trans->t('Match sequence'),
263 1
			'match.sequence.link' => $this->trans->t('See match sequence'),
264 1
			'pattern' => $this->trans->t('Pattern'),
265 1
			'matched.word' => $this->trans->t('Matched word'),
266 1
			'dictionary.name' => $this->trans->t('Dictionary name'),
267 1
			'rank' => $this->trans->t('Rank'),
268 1
			'reversed' => $this->trans->t('Reversed'),
269 1
			'guesses' => $this->trans->t('Guesses'),
270 1
			'base.guesses' => $this->trans->t('Base guesses'),
271 1
			'uppercase.variations' => $this->trans->t('Uppercase variations'),
272 1
			'leet.variations' => $this->trans->t('l33t-variations'),
273
274
			// templates/views/credential_revisions.html
275 1
			'showing.revisions' => $this->trans->t('Showing revisions of'),
276 1
			'revision.of' => $this->trans->t('Revision of'),
277 1
			'revision.edited.by' => $this->trans->t('by'),
278 1
			'no.revisions' => $this->trans->t('No revisions found.'),
279 1
			'label' => $this->trans->t('Label'),
280 1
			'restore.revision' => $this->trans->t('Restore revision'),
281 1
			'delete.revision' => $this->trans->t('Delete revision'),
282
283
			// templates/views/edit_credential.html
284 1
			'edit.credential' => $this->trans->t('Edit credential'),
285 1
			'create.credential' => $this->trans->t('Create new credential'),
286 1
			'save' => $this->trans->t('Save'),
287 1
			'cancel' => $this->trans->t('Cancel'),
288
289
			// templates/views/settings.html
290 1
			'settings' => $this->trans->t('Settings'),
291
292
			// templates/views/share_credential.html
293 1
			'share.credential' => $this->trans->t('Share credential {{credential}}'),
294 1
			'unshare' => $this->trans->t('Unshare'),
295
296
297
			// templates/views/show_vault.html
298 1
			'deleted.since' => $this->trans->t('Showing deleted since'),
299 1
			'alltime' => $this->trans->t('All time'),
300 1
			'number.filtered' => $this->trans->t('Showing {{number_filtered}} of {{credential_number}} credentials'),
301 1
			'search.credential' => $this->trans->t('Search credential...'),
302 1
			'account' => $this->trans->t('Account'),
303 1
			'password' => $this->trans->t('Password'),
304 1
			'otp' => $this->trans->t('OTP'),
305 1
			'email' => $this->trans->t('E-mail'),
306 1
			'url' => $this->trans->t('URL'),
307 1
			'notes' => $this->trans->t('Notes'),
308 1
			'files' => $this->trans->t('Files'),
309 1
			'expire.time' => $this->trans->t('Expire time'),
310 1
			'changed' => $this->trans->t('Changed'),
311 1
			'created' => $this->trans->t('Created'),
312 1
			'edit' => $this->trans->t('Edit'),
313 1
			'delete' => $this->trans->t('Delete'),
314 1
			'share' => $this->trans->t('Share'),
315 1
			'revisions' => $this->trans->t('Revisions'),
316 1
			'recover' => $this->trans->t('Recover'),
317 1
			'destroy' => $this->trans->t('Destroy'),
318 1
			'use.regex' => $this->trans->t('Use regex'),
319 1
			'sharereq.title' => $this->trans->t('You have incoming share requests.'),
320 1
			'sharereq.line1' => $this->trans->t('If you want to put the credential in a other vault,'),
321 1
			'sharereq.line2' => $this->trans->t('logout of this vault and login to the vault you want the shared credential in.'),
322 1
			'permissions' => $this->trans->t('Permissions'),
323 1
			'received.from' => $this->trans->t('Received from'),
324 1
			'date' => $this->trans->t('Date'),
325 1
			'accept' => $this->trans->t('Accept'),
326 1
			'decline' => $this->trans->t('Decline'),
327 1
			'session.time.left' => $this->trans->t('You have {{session_time}} left before logout.'),
328
329
			// templates/views/vaults.html
330 1
			'last.access' => $this->trans->t('Last accessed'),
331 1
			'never' => $this->trans->t('Never'),
332 1
			'no.vaults' => $this->trans->t('No vaults found, why not create one?'),
333 1
			'min.vault.key.strength' => $this->trans->t('Password strength must be at least: {{strength}}'),
334
335 1
			'new.vault.name' => $this->trans->t('Please give your new vault a name.'),
336 1
			'new.vault.pass' => $this->trans->t('Vault password'),
337 1
			'new.vault.passr' => $this->trans->t('Repeat vault password'),
338 1
			'new.vault.sharing_key_notice' => $this->trans->t('Your sharing key\'s will have a strength of 1024 bit, which you can change later in settings.'),
339 1
			'new.vault.create' => $this->trans->t('Create vault'),
340 1
			'go.back.vaults' => $this->trans->t('Go back to vaults'),
341 1
			'input.vault.password' => $this->trans->t('Please input the password for'),
342 1
			'vault.default' => $this->trans->t('Set this vault as default.'),
343 1
			'vault.auto.login' => $this->trans->t('Login automatically to this vault.'),
344 1
			'auto.logout' => $this->trans->t('Logout of this vault automatically after: '),
345 1
			'vault.decrypt' => $this->trans->t('Decrypt vault'),
346
347
			// templates/bookmarklet.php
348 1
			'http.warning' => $this->trans->t('Warning! Adding credentials over http can be insecure!'),
349 1
			'bm.active.vault' => $this->trans->t('Logged in to {{vault_name}}'),
350 1
			'change.vault' => $this->trans->t('Change vault'),
351
352
			// templates/main.php
353 1
			'deleted.credentials' => $this->trans->t('Deleted credentials'),
354 1
			'logout' => $this->trans->t('Logout'),
355 1
			'donate' => $this->trans->t('Donate'),
356
357
			// templates/public_share.php
358 1
			'share.page.text' => $this->trans->t('Someone has shared a credential with you.'),
359 1
			'share.page.link' => $this->trans->t('Click here to request it'),
360 1
			'share.page.link_loading' => $this->trans->t('Loading...'),
361 1
			'expired.share' => $this->trans->t('Awwhh.... credential not found. Maybe it expired'),
362
363
		);
364 1
		return new JSONResponse($translations);
365
	}
366
}
367