If you want to perform the translations in PHP, i would open the file with fopen, read it line by line and make the replacements.
If you want to do it in a shell script or within an exec function from PHP, you can try "sed". Run "man sed" for the options on the shell. Sorry, i have no tutorial for sed, maybe you can find one with google