From a0362536f3ebc4093c115cba924d804fc16eb670 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Fri, 8 Nov 2013 19:53:00 +0100 Subject: [PATCH] Extract strings from the template files. --- extract_strings.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/extract_strings.php b/extract_strings.php index 5cce9c1..df661f1 100644 --- a/extract_strings.php +++ b/extract_strings.php @@ -1,12 +1,15 @@ name == 'trans') { - echo $node->args[0]->value->value."\n"; + $translations[] = $node->args[0]->value->value; } } } @@ -24,3 +27,13 @@ try { } catch (PHPParser_Error $e) { 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); \ No newline at end of file