CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.0 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.0
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Auth
    • Core
    • Error
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
    • Network
      • Email
      • Http
    • Routing
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • AclShell
  • ApiShell
  • BakeShell
  • CommandListShell
  • ConsoleShell
  • I18nShell
  • SchemaShell
  • TestsuiteShell
  • UpgradeShell
  1: <?php
  2: /**
  3:  * Internationalization Management Shell
  4:  *
  5:  * PHP 5
  6:  *
  7:  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8:  * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  9:  *
 10:  * Licensed under The MIT License
 11:  * Redistributions of files must retain the above copyright notice.
 12:  *
 13:  * @copyright     Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
 14:  * @link          http://cakephp.org CakePHP(tm) Project
 15:  * @since         CakePHP(tm) v 1.2.0.5669
 16:  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 17:  */
 18: 
 19: App::uses('AppShell', 'Console/Command');
 20: 
 21: /**
 22:  * Shell for I18N management.
 23:  *
 24:  * @package       Cake.Console.Command
 25:  */
 26: class I18nShell extends AppShell {
 27: 
 28: /**
 29:  * Contains database source to use
 30:  *
 31:  * @var string
 32:  */
 33:     public $dataSource = 'default';
 34: 
 35: /**
 36:  * Contains tasks to load and instantiate
 37:  *
 38:  * @var array
 39:  */
 40:     public $tasks = array('DbConfig', 'Extract');
 41: 
 42: /**
 43:  * Override startup of the Shell
 44:  *
 45:  * @return mixed
 46:  */
 47:     public function startup() {
 48:         $this->_welcome();
 49:         if (isset($this->params['datasource'])) {
 50:             $this->dataSource = $this->params['datasource'];
 51:         }
 52: 
 53:         if ($this->command && !in_array($this->command, array('help'))) {
 54:             if (!config('database')) {
 55:                 $this->out(__d('cake_console', 'Your database configuration was not found. Take a moment to create one.'), true);
 56:                 return $this->DbConfig->execute();
 57:             }
 58:         }
 59:     }
 60: 
 61: /**
 62:  * Override main() for help message hook
 63:  *
 64:  * @return void
 65:  */
 66:     public function main() {
 67:         $this->out(__d('cake_console', '<info>I18n Shell</info>'));
 68:         $this->hr();
 69:         $this->out(__d('cake_console', '[E]xtract POT file from sources'));
 70:         $this->out(__d('cake_console', '[I]nitialize i18n database table'));
 71:         $this->out(__d('cake_console', '[H]elp'));
 72:         $this->out(__d('cake_console', '[Q]uit'));
 73: 
 74:         $choice = strtolower($this->in(__d('cake_console', 'What would you like to do?'), array('E', 'I', 'H', 'Q')));
 75:         switch ($choice) {
 76:             case 'e':
 77:                 $this->Extract->execute();
 78:             break;
 79:             case 'i':
 80:                 $this->initdb();
 81:             break;
 82:             case 'h':
 83:                 $this->out($this->OptionParser->help());
 84:             break;
 85:             case 'q':
 86:                 exit(0);
 87:             break;
 88:             default:
 89:                 $this->out(__d('cake_console', 'You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.'));
 90:         }
 91:         $this->hr();
 92:         $this->main();
 93:     }
 94: 
 95: /**
 96:  * Initialize I18N database.
 97:  *
 98:  * @return void
 99:  */
100:     public function initdb() {
101:         $this->dispatchShell('schema create i18n');
102:     }
103: 
104: /**
105:  * Get and configure the Option parser
106:  *
107:  * @return ConsoleOptionParser
108:  */
109:     public function getOptionParser() {
110:         $parser = parent::getOptionParser();
111:         return $parser->description(
112:             __d('cake_console', 'I18n Shell initializes i18n database table for your application and generates .pot files(s) with translations.')
113:             )->addSubcommand('initdb', array(
114:                 'help' => __d('cake_console', 'Initialize the i18n table.')
115:             ))->addSubcommand('extract', array(
116:                 'help' => __d('cake_console', 'Extract the po translations from your application'),
117:                 'parser' => $this->Extract->getOptionParser()
118:             ));
119:     }
120: }
121: 
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs