-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathBladeCodeExtractor.php
More file actions
66 lines (57 loc) · 1.88 KB
/
BladeCodeExtractor.php
File metadata and controls
66 lines (57 loc) · 1.88 KB
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
<?php
namespace WP_CLI\I18n;
use Exception;
use Gettext\Translations;
use WP_CLI;
final class BladeCodeExtractor extends BladeGettextExtractor {
use IterableCodeExtractor;
public static $options = [
'extractComments' => [ 'translators', 'Translators' ],
'constants' => [],
'functions' => [
'__' => 'text_domain',
'esc_attr__' => 'text_domain',
'esc_html__' => 'text_domain',
'esc_xml__' => 'text_domain',
'_e' => 'text_domain',
'esc_attr_e' => 'text_domain',
'esc_html_e' => 'text_domain',
'esc_xml_e' => 'text_domain',
'_x' => 'text_context_domain',
'_ex' => 'text_context_domain',
'esc_attr_x' => 'text_context_domain',
'esc_html_x' => 'text_context_domain',
'esc_xml_x' => 'text_context_domain',
'_n' => 'single_plural_number_domain',
'_nx' => 'single_plural_number_context_domain',
'_n_noop' => 'single_plural_domain',
'_nx_noop' => 'single_plural_context_domain',
// Compat.
'_' => 'gettext', // Same as 'text_domain'.
// Deprecated.
'_c' => 'text_domain',
'_nc' => 'single_plural_number_domain',
'__ngettext' => 'single_plural_number_domain',
'__ngettext_noop' => 'single_plural_domain',
],
];
protected static $functionsScannerClass = 'WP_CLI\I18n\PhpFunctionsScanner';
/**
* {@inheritdoc}
*/
public static function fromString( $text, Translations $translations, array $options = [] ) {
WP_CLI::debug( "Parsing file {$options['file']}", 'make-pot' );
try {
self::fromStringMultiple( $text, [ $translations ], $options );
} catch ( Exception $exception ) {
WP_CLI::debug(
sprintf(
'Could not parse file %1$s: %2$s',
$options['file'],
$exception->getMessage()
),
'make-pot'
);
}
}
}