-
Notifications
You must be signed in to change notification settings - Fork 8
/
NetteGettextExtractor.php
124 lines (112 loc) · 2.89 KB
/
NetteGettextExtractor.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
<?php
/**
* GettextExtractor
*
* Cool tool for automatic extracting gettext strings for translation
*
* Works best with Nette Framework
*
* This source file is subject to the New BSD License.
*
* @copyright Copyright (c) 2009 Karel Klima
* @license New BSD License
* @package Nette Extras
* @version GettextExtractor 2.0, 2009-10-21
*/
require dirname(__FILE__) . '/GettextExtractor.php';
/**
* NetteGettextExtractor tool - designed specially for use with Nette Framework
*
* @author Karel Klima
* @copyright Copyright (c) 2009 Karel Klíma
* @package Nette Extras
*/
class NetteGettextExtractor extends GettextExtractor
{
/** @var array */
protected $functionMap = array(
// standard translation functions
'translate' => 1,
'_' => 1,
// form translations
'setText' => 1,
'setEmptyValue' => 1,
'addButton' => 2,
'addCheckbox' => 2,
'addError' => 1,
'addFile' => 2,
'addGroup' => 1,
'addImage' => 3,
'addMultiSelect' => 2,
'addPassword' => 2,
'addRadioList' => 2,
'addRule' => 2,
'addSelect' => 2,
'addSubmit' => 2,
'addText' => 2,
'addTextArea' => 2
);
/**
* Setup mandatory filters
* @param string|bool $logToFile
*/
public function __construct($logToFile = FALSE)
{
parent::__construct($logToFile);
// Clean up...
$this->removeAllFilters();
// Set basic filters
$this->setFilter('php', 'PHP')
->setFilter('phtml', 'PHP')
->setFilter('phtml', 'NetteLatte')
->setFilter('latte', 'NetteLatte')
->setFilter('latte', 'PHP');
$php = $this->getFilter('PHP');
$php->addFunction('translate')
->addFunction('_');
$this->getFilter('NetteLatte')->addPrefix('!_')->addPrefix('_');
}
/**
* Optional setup of Forms translations
* @return NetteGettextExtractor
*/
public function setupForms()
{
$php = $this->getFilter('PHP');
$php->addFunction('setText')
->addFunction('setEmptyValue')
->addFunction('setValue')
->addFunction('addButton', 2)
->addFunction('addCheckbox', 2)
->addFunction('addError')
->addFunction('addFile', 2)
->addFunction('addGroup')
->addFunction('addImage', 3)
->addFunction('addmultiSelect', 2)
->addFunction('addPassword', 2)
->addFunction('addRadioList', 2)
->addFunction('addRule', 2)
->addFunction('addSelect', 2)
->addFunction('addSubmit', 2)
->addFunction('addText', 2)
->addFunction('addTextArea', 2);
return $this;
}
/**
* Optional setup of DataGrid component translations
* @return NetteGettextExtractor
*/
public function setupDataGrid()
{
$php = $this->getFilter('PHP');
$php->addFunction('addColumn', 2)
->addFunction('addNumericColumn', 2)
->addFunction('addDateColumn', 2)
->addFunction('addCheckboxColumn', 2)
->addFunction('addImageColumn', 2)
->addFunction('addPositionColumn', 2)
->addFunction('addActionColumn')
->addFunction('addAction');
return $this;
}
}