File tree 4 files changed +22
-3
lines changed
4 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
5
5
The format is based on [ Keep a Changelog] ( http://keepachangelog.com/ )
6
6
and this project adheres to [ Semantic Versioning] ( http://semver.org/ ) .
7
7
8
+ ## [ 1.1.1] - Unreleased
9
+ ### Fixed
10
+ - Extract comments of functions prepended with echo, print or return [ #6 ]
11
+ - Tested extracted comments from code
12
+
8
13
## [ 1.1.0] - 2019-11-19
9
14
### Added
10
15
- In v1.0, non-scalar arguments (others than string, int and float) were discarded. Now the arrays are included too [ #5 ]
@@ -18,6 +23,8 @@ First version
18
23
19
24
[ #1 ] : https://github.com/php-gettext/PHP-Scanner/issues/1
20
25
[ #5 ] : https://github.com/php-gettext/PHP-Scanner/issues/5
26
+ [ #6 ] : https://github.com/php-gettext/PHP-Scanner/issues/6
21
27
28
+ [ 1.1.1 ] : https://github.com/php-gettext/PHP-Scanner/compare/v1.1.0...HEAD
22
29
[ 1.1.0 ] : https://github.com/php-gettext/PHP-Scanner/compare/v1.0.1...v1.1.0
23
30
[ 1.0.1 ] : https://github.com/php-gettext/PHP-Scanner/compare/v1.0.0...v1.0.1
Original file line number Diff line number Diff line change @@ -30,6 +30,12 @@ $phpScanner = new PhpScanner(
30
30
Translations::create('domain3')
31
31
);
32
32
33
+ //Set a default domain, so any translations with no domain specified, will be added to that domain
34
+ $phpScanner->setDefaultDomain('domain1');
35
+
36
+ //Extract all comments starting with 'i18n:' and 'Translators:'
37
+ $phpScanner->extractCommentsStartingWith('i18n:', 'Translators:');
38
+
33
39
//Scan files
34
40
foreach (glob('*.php') as $file) {
35
41
$phpScanner->scanFile($file);
@@ -38,8 +44,7 @@ foreach (glob('*.php') as $file) {
38
44
//Save the translations in .po files
39
45
$generator = new PoGenerator();
40
46
41
- foreach ($phpScanner->getTranslations() as $translations) {
42
- $domain = $translations->getDomain();
47
+ foreach ($phpScanner->getTranslations() as $domain => $translations) {
43
48
$generator->generateFile($translations, "locales/{$domain}.po");
44
49
}
45
50
```
Original file line number Diff line number Diff line change 20
20
"require" : {
21
21
"php" : " ^7.2" ,
22
22
"nikic/php-parser" : " ^4.2" ,
23
- "gettext/gettext" : " ^5.1 "
23
+ "gettext/gettext" : " dev-master "
24
24
},
25
25
"require-dev" : {
26
26
"phpunit/phpunit" : " ^8.0" ,
Original file line number Diff line number Diff line change @@ -30,11 +30,18 @@ public function testPhpCodeScanner()
30
30
$ this ->assertCount (1 , $ domain3 );
31
31
32
32
$ scanner ->setDefaultDomain ('domain1 ' );
33
+ $ scanner ->extractCommentsStartingWith ('' );
33
34
$ scanner ->scanFile ($ file );
34
35
35
36
$ this ->assertCount (39 , $ domain1 );
36
37
$ this ->assertCount (4 , $ domain2 );
37
38
$ this ->assertCount (1 , $ domain3 );
39
+
40
+ //Extract comments
41
+ $ translation = $ domain1 ->find ('CONTEXT ' , 'All comments ' );
42
+ $ this ->assertNotNull ($ translation );
43
+ $ this ->assertSame ([$ file => [66 ]], $ translation ->getReferences ()->toArray ());
44
+ $ this ->assertCount (1 , $ translation ->getExtractedComments ());
38
45
}
39
46
40
47
public function testInvalidFunction ()
You can’t perform that action at this time.
0 commit comments