Search for function call in php in order to generate a translation file

Viewed 859

I am developing a php website that needs to be multilingual. For this reason, I implemented a translation function which has the following header:

function t($string, $replace_pairs = array(), $language = NULL)

Basically, this function is called like this in multiples files of my project:

echo '<p>' . t('Hello world!') . '</p>';
$hello_String = t("Hello @name!", array('@name'=>$username));

I haven't generated the translation strings yet and I would like to generate multiple translation file automatically (one for each language).

What I am looking for is a bash program (or a single command, using grep for example) that would look for every call to this t() function and generate a php file with the following structure:

<?php
/* Translation file "fr.php" */
$strings['fr']['Hello world!'] = '';
$strings['fr']['Hello @name!'] = '';

Has anyone ever encountered this situation and could help me with this ?

Thank you very much.

Kind regards,

Matthieu

6 Answers
Related