• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

contributte / datagrid / 8230471191

11 Mar 2024 09:25AM UTC coverage: 34.102%. First build
8230471191

Pull #1060

github

radimvaculik
Fix phpstan
Pull Request #1060: [7.x] Next

117 of 435 new or added lines in 54 files covered. (26.9%)

1124 of 3296 relevant lines covered (34.1%)

0.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.0
/src/Localization/SimpleTranslator.php
1
<?php declare(strict_types = 1);
2

3
namespace Contributte\Datagrid\Localization;
4

5
use Nette\Localization\Translator;
6

7
class SimpleTranslator implements Translator
8
{
9

10
        private array $dictionary = [
11
                'contributte_datagrid.no_item_found_reset' => 'No items found. You can reset the filter',
12
                'contributte_datagrid.no_item_found' => 'No items found.',
13
                'contributte_datagrid.here' => 'here',
14
                'contributte_datagrid.items' => 'Items',
15
                'contributte_datagrid.all' => 'all',
16
                'contributte_datagrid.from' => 'from',
17
                'contributte_datagrid.reset_filter' => 'Reset filter',
18
                'contributte_datagrid.group_actions' => 'Group actions',
19
                'contributte_datagrid.show' => 'Show',
20
                'contributte_datagrid.add' => 'Add',
21
                'contributte_datagrid.edit' => 'Edit',
22
                'contributte_datagrid.show_all_columns' => 'Show all columns',
23
                'contributte_datagrid.show_default_columns' => 'Show default columns',
24
                'contributte_datagrid.hide_column' => 'Hide column',
25
                'contributte_datagrid.action' => 'Action',
26
                'contributte_datagrid.previous' => 'Previous',
27
                'contributte_datagrid.next' => 'Next',
28
                'contributte_datagrid.choose' => 'Choose',
29
                'contributte_datagrid.choose_input_required' => 'Group action text not allow empty value',
30
                'contributte_datagrid.execute' => 'Execute',
31
                'contributte_datagrid.save' => 'Save',
32
                'contributte_datagrid.cancel' => 'Cancel',
33
                'contributte_datagrid.multiselect_choose' => 'Choose',
34
                'contributte_datagrid.multiselect_selected' => '{0} selected',
35
                'contributte_datagrid.filter_submit_button' => 'Filter',
36
                'contributte_datagrid.show_filter' => 'Show filter',
37
                'contributte_datagrid.per_page_submit' => 'Change',
38
        ];
39

40
        public function __construct(array $dictionary = [])
1✔
41
        {
42
                // BC support for 'ublaboo' translations
43
                $oldPrefix = 'ublaboo_';
1✔
44
                $newPrefix = 'contributte_';
1✔
45
                foreach ($dictionary as $key => $value) {
1✔
46
                        if (str_starts_with($key, $oldPrefix)) {
1✔
NEW
47
                                $newKey = $newPrefix . substr($key, strlen($oldPrefix));
×
48
                                // Only change the keys that are in the default $dictionary (other keys are left as-is)
NEW
49
                                if (array_key_exists($newKey, $this->dictionary)) {
×
NEW
50
                                        trigger_error(sprintf("Translation key '%s' is deprecated, please use '%s' instead", $key, $newKey), E_USER_DEPRECATED);
×
NEW
51
                                        unset($dictionary[$key]);
×
NEW
52
                                        $dictionary[$newKey] = $value;
×
53
                                }
54
                        }
55
                }
56

57
                $this->dictionary = array_merge($this->dictionary, $dictionary);
1✔
58
        }
1✔
59

60
        public function translate(mixed $message, mixed ...$parameters): string
1✔
61
        {
62
                return $this->dictionary[$message] ?? $message;
1✔
63
        }
64

65
        public function setDictionary(array $dictionary): void
66
        {
67
                $this->dictionary = $dictionary;
×
68
        }
69

70
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc