Extract strings from the template files.
This commit is contained in:
parent
c8c34e8c7c
commit
a0362536f3
1 changed files with 14 additions and 1 deletions
|
@ -1,12 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
require 'vendor/autoload.php';
|
require 'vendor/autoload.php';
|
||||||
|
|
||||||
|
$translations = array();
|
||||||
|
|
||||||
class MyNodeVisitor extends PHPParser_NodeVisitorAbstract
|
class MyNodeVisitor extends PHPParser_NodeVisitorAbstract
|
||||||
{
|
{
|
||||||
public function enterNode(PHPParser_Node $node) {
|
public function enterNode(PHPParser_Node $node) {
|
||||||
|
global $translations;
|
||||||
if ($node instanceof PHPParser_Node_Expr_MethodCall) {
|
if ($node instanceof PHPParser_Node_Expr_MethodCall) {
|
||||||
if ($node->name == 'trans') {
|
if ($node->name == 'trans') {
|
||||||
echo $node->args[0]->value->value."\n";
|
$translations[] = $node->args[0]->value->value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,3 +27,13 @@ try {
|
||||||
} catch (PHPParser_Error $e) {
|
} catch (PHPParser_Error $e) {
|
||||||
echo 'Parse Error: ', $e->getMessage();
|
echo 'Parse Error: ', $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach(glob('templates/*.twig') as $file) {
|
||||||
|
$content = file_get_contents($file);
|
||||||
|
preg_match_all('/{% trans %}(.*){% endtrans %}/',$content,$matches);
|
||||||
|
$translations = array_merge($translations,$matches[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$translations = array_unique($translations);
|
||||||
|
|
||||||
|
print_r($translations);
|
Reference in a new issue