Overview

Namespaces

  • Cron
  • None

Classes

  • _HtmlGrid_TableOut
  • _TransactionModel_RawSaveOperation
  • AccessControlComponent
  • AccessControlHelper
  • ActionListHelper
  • ActiveDirectoryUtils
  • AddCurrentPidToSchedulingShellCallLogs
  • AnonymousFunctionOperation
  • ArrayUtil
  • AssociationIntegrityBehavior
  • AtomicOperation
  • AuthenticationComponent
  • AuthenticationController
  • AuthenticationUser
  • AutocompleteDatasourceComponent
  • BaseModelComponent
  • Basics
  • CakeLayersHelper
  • CheckAndRunShell
  • ClassSearcher
  • CommandLineUtil
  • CommonValidationBehavior
  • ConfigurableShellCallsSchedulingTask
  • ConfigurationKey
  • ConfigurationKeys
  • ConfigurationKeysController
  • Context
  • ContextComponent
  • ContextHelper
  • Contexts
  • ControllerInspector
  • ControllerMenuHelper
  • CreateJournalingTables
  • CreateTableConfigurationKeys
  • CreateTableSchedulingConfigurableShellCalls
  • CreateTableSchedulingShellCallLogs
  • CreateTableSettedConfigurationKeys
  • CreateTableUserResetPasswordRequests
  • CreateTableUsers
  • CronSchedulingInstaller
  • CronValidationBehavior
  • CssBox
  • CssController
  • CssProperties
  • CssShell
  • CsvUtil
  • CustomDataModel
  • DatasourceDumperManager
  • DateTimeInput
  • DependencyShell
  • DetailHelper
  • DumperShell
  • ExtendedFieldsAccessControl
  • ExtendedFieldSet
  • ExtendedFieldSetHelper
  • ExtendedFieldsParser
  • ExtendedFormHelper
  • ExtendedHasManyAppModel
  • ExtendedOperationsBehavior
  • FieldDefinition
  • FieldRowDefinition
  • FieldSetDefinition
  • FieldSetLayoutHelper
  • FileOperations
  • FileOperations_Rename
  • FileOperations_SymLink
  • FileOperations_Touch
  • FileOperations_Unlink
  • FileSystem
  • FixConfigurationKeysPrimaryKey
  • FixSettedConfigurationKeysPrimaryKey
  • HasManyUtilsBehavior
  • HtmlDocument
  • HtmlGrid
  • HtmlGrid_Cell
  • HttpClient
  • HttpResponse
  • ImapClient
  • ImapMailBox
  • ImapParserShell
  • IncludePath
  • InputMasked
  • InputSearchable
  • InputsOnSubmit
  • InstallShell
  • JenkinsBuildShell
  • Journal
  • JournalDetail
  • JournalizedBehavior
  • JsonResponseComponent
  • LayoutsHelper
  • Ldap
  • LdapUtils
  • ListFieldSet
  • ListFieldSetHelper
  • ListsHelper
  • MailParser
  • Make
  • MenuHelper
  • MigrationAllPluginsShell
  • ModelOperations
  • ModelOperations_Delete
  • ModelOperations_Save
  • ModelTraverser
  • MysqlDumper
  • OpenLdapUtils
  • PaginatorUtilComponent
  • PaginatorUtilComponentFilter
  • PaginatorUtilHelper
  • Plugin
  • PluginManager
  • Reflections
  • RenameEnabledToActiveFromUsersTable
  • RunShellCallShell
  • ScaffoldUtilComponent
  • ScaffoldUtilHelper
  • Scheduling
  • SchedulingConfigurableShellCall
  • SchedulingConfigurableShellCallsController
  • SchedulingShellCallLog
  • SchedulingShellCallLogsController
  • SettedConfigurationKey
  • StuffreposPluginsRename
  • TimeZoneBehavior
  • TransactionModel
  • TransactionOperation
  • Translator
  • TranslatorShell
  • User
  • UserAuthenticationComponent
  • UserChangePassword
  • UserResetPassword
  • UserResetPasswordRequest
  • UserResetPasswordRequestSubmission
  • UsersController
  • ViewUtilHelper

Interfaces

  • AccessControlFilter
  • CommitableOperation
  • DatasourceDumper
  • MakeListener
  • SchedulingInstaller
  • TasksObject
  • UndoableOperation

Exceptions

  • LdapObjectNotWritableException
  • ModelTraverserException
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: App::uses('Translator', 'Base.Lib');
 4: App::uses('FileSystem', 'Base.Lib');
 5: 
 6: class TranslatorShell extends Shell {
 7: 
 8:     /**
 9:      * get the option parser.
10:      *
11:      * @return ConsoleOptionParser
12:      */
13:     public function getOptionParser() {
14:         $parser = parent::getOptionParser();
15:         $parser->addSubcommand('i18n_extract');
16:         $parser->addSubcommand('terms');
17:         $parser->addSubcommand('terms_file');
18:         return $parser;
19:     }
20: 
21:     public function i18n_extract() {
22:         $directoryWithTerms = $this->_directoryWithTermsToTranslate();
23:         $plugins = $this->_pluginPaths();
24:         $shell = 'i18n extract --app ' . APP .
25:                 ' --paths ' . APP . ',' . $directoryWithTerms . ',' . implode(',', $plugins) .
26:                 ' --extract-core no' .
27:                 ' --merge no' .
28:                 ' --output ' . APP . 'Locale' .
29:                 ' --overwrite yes';
30:         $this->dispatchShell($shell);
31:         FileSystem::recursiveRemoveDirectory($directoryWithTerms);
32:     }
33: 
34:     public function terms() {
35:         foreach (Translator::termsToTranslate() as $plugin => $terms) {
36:             foreach ($terms as $term) {
37:                 $this->out("<info>$plugin</info>|$term|");
38:             }
39:         }
40:     }
41: 
42:     public function terms_file() {
43:         echo $this->out($this->_termsToTranslateFileContent());
44:     }
45: 
46:     private function _pluginPaths() {
47:         $paths = array();
48:         foreach (CakePlugin::loaded() as $plugin) {
49:             switch ($plugin) {
50:                 case 'Migrations':
51:                     break;
52: 
53:                 default:
54:                     $paths[] = CakePlugin::path($plugin);
55:             }
56:         }
57:         return $paths;
58:     }
59: 
60:     private function _directoryWithTermsToTranslate() {
61:         $tempDir = FileSystem::createTemporaryDirectory();
62:         $tempFile = tempnam($tempDir, 'to_translate') . '.php';
63:         file_put_contents($tempFile, $this->_termsToTranslateFileContent());
64:         return $tempDir;
65:     }
66: 
67:     private function _termsToTranslateFileContent() {
68:         $b = "<?php\n";
69:         foreach (Translator::termsToTranslate() as $plugin => $terms) {
70:             foreach ($terms as $term) {
71:                 if ($plugin == '') {
72:                     $b .= '__("' . addslashes($term) . '");' . PHP_EOL;
73:                 } else {
74:                     $b .= '__d("' . $plugin . '","' . addslashes($term) . '");' . PHP_EOL;
75:                 }
76:             }
77:         }
78:         return $b;
79:     }
80: 
81: }
82: 
API documentation generated by ApiGen 2.8.0