Completed
Push — master ( 76852c...676732 )
by Sander
03:09
created

TranslationController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 352
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 96.48%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 352
ccs 247
cts 256
cp 0.9648
rs 10
wmc 2
lcom 1
cbo 0

2 Methods

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