Subversion-Projekte lars-tiefland.cakephp

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/* SVN FILE: $Id: i18n.php 7945 2008-12-19 02:16:01Z gwoo $ */
3
/**
4
 * Short description for file.
5
 *
6
 * Long description for file
7
 *
8
 * PHP versions 4 and 5
9
 *
10
 * CakePHP(tm) :  Rapid Development Framework (http://www.cakephp.org)
11
 * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
12
 *
13
 * Licensed under The MIT License
14
 * Redistributions of files must retain the above copyright notice.
15
 *
16
 * @filesource
17
 * @copyright     Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
18
 * @link          http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
19
 * @package       cake
20
 * @subpackage    cake.cake.console.libs
21
 * @since         CakePHP(tm) v 1.2.0.5669
22
 * @version       $Revision: 7945 $
23
 * @modifiedby    $LastChangedBy: gwoo $
24
 * @lastmodified  $Date: 2008-12-18 18:16:01 -0800 (Thu, 18 Dec 2008) $
25
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
26
 */
27
/**
28
 * Shell for I18N management.
29
 *
30
 * @package       cake
31
 * @subpackage    cake.cake.console.libs
32
 */
33
class I18nShell extends Shell {
34
/**
35
 * Contains database source to use
36
 *
37
 * @var string
38
 * @access public
39
 */
40
	var $dataSource = 'default';
41
/**
42
 * Contains tasks to load and instantiate
43
 *
44
 * @var array
45
 * @access public
46
 */
47
	var $tasks = array('DbConfig', 'Extract');
48
/**
49
 * Override startup of the Shell
50
 *
51
 * @access public
52
 */
53
	function startup() {
54
		$this->_welcome();
55
		if (isset($this->params['datasource'])) {
56
			$this->dataSource = $this->params['datasource'];
57
		}
58
 
59
		if ($this->command && !in_array($this->command, array('help'))) {
60
			if (!config('database')) {
61
				$this->out(__('Your database configuration was not found. Take a moment to create one.', true), true);
62
				return $this->DbConfig->execute();
63
			}
64
		}
65
	}
66
/**
67
 * Override main() for help message hook
68
 *
69
 * @access public
70
 */
71
	function main() {
72
		$this->out(__('I18n Shell', true));
73
		$this->hr();
74
		$this->out(__('[E]xtract POT file from sources', true));
75
		$this->out(__('[I]nitialize i18n database table', true));
76
		$this->out(__('[H]elp', true));
77
		$this->out(__('[Q]uit', true));
78
 
79
		$choice = strtoupper($this->in(__('What would you like to do?', true), array('E', 'I', 'H', 'Q')));
80
		switch ($choice) {
81
			case 'E':
82
				$this->Extract->execute();
83
			break;
84
			case 'I':
85
				$this->initdb();
86
			break;
87
			case 'H':
88
				$this->help();
89
			break;
90
			case 'Q':
91
				exit(0);
92
			break;
93
			default:
94
				$this->out(__('You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.', true));
95
		}
96
		$this->hr();
97
		$this->main();
98
	}
99
/**
100
 * Initialize I18N database.
101
 *
102
 * @access public
103
 */
104
	function initdb() {
105
		$this->Dispatch->args = array('schema', 'run', 'create', 'i18n');
106
		$this->Dispatch->dispatch();
107
	}
108
/**
109
 * Show help screen.
110
 *
111
 * @access public
112
 */
113
	function help() {
114
		$this->hr();
115
		$this->out(__('I18n Shell:', true));
116
		$this->hr();
117
		$this->out(__('I18n Shell initializes i18n database table for your application', true));
118
		$this->out(__('and generates .pot file(s) with translations.', true));
119
		$this->hr();
120
		$this->out(__('usage:', true));
121
		$this->out('   cake i18n help');
122
		$this->out('   cake i18n initdb [-datasource custom]');
123
		$this->out('');
124
		$this->hr();
125
 
126
		$this->Extract->help();
127
	}
128
}
129
?>