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