00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 class I18nShell extends Shell {
00034
00035
00036
00037
00038
00039
00040 var $dataSource = 'default';
00041
00042
00043
00044
00045
00046
00047 var $tasks = array('DbConfig', 'Extract');
00048
00049
00050
00051
00052
00053 function startup() {
00054 $this->_welcome();
00055 if (isset($this->params['datasource'])) {
00056 $this->dataSource = $this->params['datasource'];
00057 }
00058
00059 if ($this->command && !in_array($this->command, array('help'))) {
00060 if (!config('database')) {
00061 $this->out(__('Your database configuration was not found. Take a moment to create one.', true), true);
00062 return $this->DbConfig->execute();
00063 }
00064 }
00065 }
00066
00067
00068
00069
00070
00071 function main() {
00072 $this->out(__('I18n Shell', true));
00073 $this->hr();
00074 $this->out(__('[E]xtract POT file from sources', true));
00075 $this->out(__('[I]nitialize i18n database table', true));
00076 $this->out(__('[H]elp', true));
00077 $this->out(__('[Q]uit', true));
00078
00079 $choice = strtoupper($this->in(__('What would you like to do?', true), array('E', 'I', 'H', 'Q')));
00080 switch ($choice) {
00081 case 'E':
00082 $this->Extract->execute();
00083 break;
00084 case 'I':
00085 $this->initdb();
00086 break;
00087 case 'H':
00088 $this->help();
00089 break;
00090 case 'Q':
00091 exit(0);
00092 break;
00093 default:
00094 $this->out(__('You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.', true));
00095 }
00096 $this->hr();
00097 $this->main();
00098 }
00099
00100
00101
00102
00103
00104 function initdb() {
00105 $this->Dispatch->args = array('schema', 'run', 'create', 'i18n');
00106 $this->Dispatch->dispatch();
00107 }
00108
00109
00110
00111
00112
00113 function help() {
00114 $this->hr();
00115 $this->out(__('I18n Shell:', true));
00116 $this->hr();
00117 $this->out(__('I18n Shell initializes i18n database table for your application', true));
00118 $this->out(__('and generates .pot file(s) with translations.', true));
00119 $this->hr();
00120 $this->out(__('usage:', true));
00121 $this->out(' cake i18n help');
00122 $this->out(' cake i18n initdb [-datasource custom]');
00123 $this->out('');
00124 $this->hr();
00125
00126 $this->Extract->help();
00127 }
00128 }
00129 ?>