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.4 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.4
      • 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
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
      • Validator
    • Network
      • Email
      • Http
    • Routing
      • Filter
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

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