As said there are more ways to do this. This is just one take on it, I'm not pretending this is the best way to do it (in fact, my preferred way would be totally different, including not using PHP).
Use opendir()
to create a list of files to scan. On the documentation page some examples are shown that are quite useful for your purpose. Loop through the files and get their contents using, for example, file_get_contents()
. Then use preg_match_all()
on that content to find the strings you want. An example regex, based on the content in question, would be /\{{2}\s*([^|]+)\|trans\s*\}{2}/i
.