/var/www/html_sp/wp-content/plugins/loco-translate/src/cli/Commands.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
/**
 * Loco Translate commands
 * @codeCoverageIgnore
 */
class Loco_cli_Commands {


    
/**
     * Sync translation files with the available source strings
     * 
     * ## OPTIONS
     * 
     * [<filter>]
     * : Restrict to a type of bundle (plugins|themes|core); a single bundle (e.g. plugins:<handle>); or a Text Domain
     * 
     * [--locale=<code>]
     * : Restrict to one or more locales. Separate multiple codes with commas.
     * 
     * [--fuzziness=<percent>]
     * : Override plugin settings for fuzzy matching tolerance (0-100).
     * 
     * [--noop]
     * : Specify dry run. Makes no changes on disk.
     * 
     * [--force]
     * : Update even when nothing has changed. Useful for recompiling MO/JSON.
     * 
     * ## EXAMPLES
     * 
     * wp loco sync plugins
     * 
     * @param string[] $args
     * @param string[] $opts
     */
    
public function sync$args$opts ){
        if( 
array_key_exists('fuzziness',$opts) ){
            
Loco_data_Settings::get()->fuzziness = (int) $opts['fuzziness'];
        }
        try {
            
Loco_cli_SyncCommand::run (
                
Loco_cli_Utils::collectProjects( isset($args[0]) ? $args[0] : '' ),
                
Loco_cli_Utils::collectLocales( isset($opts['locale']) ? $opts['locale'] : '' ),
                
Loco_cli_Utils::bool($opts,'noop'),
                
Loco_cli_Utils::bool($opts,'force')
            );
        }
        catch( 
Loco_error_Exception $e ){
            
WP_CLI::error$e->getMessage() );
        }
    }


    
/**
     * Extract available source strings
     * 
     * ## OPTIONS
     * 
     * [<filter>]
     * : Restrict to a type of bundle (plugins|themes|core); a single bundle (e.g. plugins:<handle>); or a Text Domain
     * 
     * [--maxsize=<size>]
     * : Override plugin settings for maximum PHP file size
     * 
     * [--noop]
     * : Specify dry run. Makes no changes on disk.
     * 
     * [--force]
     * : Update even when nothing has changed. Useful for updating meta properties.
     * 
     * ## EXAMPLES
     *
     * wp loco extract core --maxsize=400K
     *
     * @param string[] $args
     * @param string[] $opts
     */
    
public function extract$args$opts ){
        try {
            if( 
array_key_exists('maxsize',$opts) ){
                
Loco_data_Settings::get()->max_php_size $opts['maxsize'];
            }
            
Loco_cli_ExtractCommand::run (
                
Loco_cli_Utils::collectProjects( isset($args[0]) ? $args[0] : '' ),
                
Loco_cli_Utils::bool($opts,'noop'),
                
Loco_cli_Utils::bool($opts,'force')
            );
        }
        catch( 
Loco_error_Exception $e ){
            
WP_CLI::error$e->getMessage() );
        }
    }


    
/**
     * EXPERIMENTAL. Attempts to install translation source files from an external repository.
     * Use this to replace *installed* PO files if they are missing or have been purged of script translations.
     *
     * ## OPTIONS
     *
     * [<filter>]
     * : Restrict to a type of bundle (plugins|themes|core); a single bundle (e.g. plugins:<handle>); or a Text Domain
     * 
     * [--locale=<code>]
     * : Restrict to one or more locales. Separate multiple codes with commas.
     * 
     * [--trunk]
     * : Install strings for upcoming dev version as opposed to latest stable
     *
     * ## EXAMPLES
     *
     * wp loco fetch loco-translate --locale=en_GB
     *
     * @param string[] $args
     * @param string[] $opts
     */
    
public function fetch$args$opts ){
        try {
            
Loco_cli_FetchCommand::run (
                
Loco_cli_Utils::collectProjects( isset($args[0]) ? $args[0] : '' ),
                
Loco_cli_Utils::collectLocales( isset($opts['locale']) ? $opts['locale'] : '' ),
                 [
                    
'trunk' => Loco_cli_Utils::bool($opts,'trunk')
                ]
            );
        }
        catch( 
Loco_error_Exception $e ){
            
WP_CLI::error$e->getMessage() );
        }        
    }

}