SimpleTranslator   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 62.5%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 72
rs 10
ccs 5
cts 8
cp 0.625

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A translate() 0 4 2
A setDictionary() 0 4 1
1
<?php
2
3
/**
4
 * @copyright   Copyright (c) 2015 ublaboo <[email protected]>
5
 * @author      Pavel Janda <[email protected]>
6
 * @package     Ublaboo
7
 */
8
9
namespace Ublaboo\DataGrid\Localization;
10
11
use Nette;
12
use Nette\SmartObject;
13
14 1
class SimpleTranslator implements Nette\Localization\ITranslator
15
{
16
17 1
	use SmartObject;
18
19
	/**
20
	 * @var array
21
	 */
22
	private $dictionary = [
23
		'ublaboo_datagrid.no_item_found_reset' => 'No items found. You can reset the filter',
24
		'ublaboo_datagrid.no_item_found' => 'No items found.',
25
		'ublaboo_datagrid.here' => 'here',
26
		'ublaboo_datagrid.items' => 'Items',
27
		'ublaboo_datagrid.all' => 'all',
28
		'ublaboo_datagrid.from' => 'from',
29
		'ublaboo_datagrid.reset_filter' => 'Reset filter',
30
		'ublaboo_datagrid.group_actions' => 'Group actions',
31
		'ublaboo_datagrid.show' => 'Show',
32
		'ublaboo_datagrid.add' => 'Add',
33
		'ublaboo_datagrid.edit' => 'Edit',
34
		'ublaboo_datagrid.show_all_columns' => 'Show all columns',
35
		'ublaboo_datagrid.show_default_columns' => 'Show default columns',
36
		'ublaboo_datagrid.hide_column' => 'Hide column',
37
		'ublaboo_datagrid.action' => 'Action',
38
		'ublaboo_datagrid.previous' => 'Previous',
39
		'ublaboo_datagrid.next' => 'Next',
40
		'ublaboo_datagrid.choose' => 'Choose',
41
		'ublaboo_datagrid.choose_input_required' => 'Group action text not allow empty value',
42
		'ublaboo_datagrid.execute' => 'Execute',
43
		'ublaboo_datagrid.save' => 'Save',
44
		'ublaboo_datagrid.cancel' => 'Cancel',
45
		'ublaboo_datagrid.multiselect_choose' => 'Choose',
46
		'ublaboo_datagrid.multiselect_selected' => '{0} selected',
47
		'ublaboo_datagrid.filter_submit_button' => 'Filter',
48
		'ublaboo_datagrid.show_filter' => 'Show filter',
49
		'ublaboo_datagrid.per_page_submit' => 'Change',
50
	];
51
52
53
	/**
54
	 * @param array $dictionary
55
	 */
56
	public function __construct($dictionary = null)
57
	{
58 1
		if (is_array($dictionary)) {
59
			$this->dictionary = $dictionary;
60
		}
61 1
	}
62
63
64
	/**
65
	 * Translates the given string
66
	 * 
67
	 * @param  string
68
	 * @param  int
69
	 * @return string
70
	 */
71
	public function translate($message, $count = null)
72
	{
73 1
		return isset($this->dictionary[$message]) ? $this->dictionary[$message] : $message;
74
	}
75
76
77
	/**
78
	 * Set translator dictionary
79
	 * @param array $dictionary
80
	 */
81
	public function setDictionary(array $dictionary)
82
	{
83
		$this->dictionary = $dictionary;
84
	}
85
}
86