There are variety of .PHP language files, but they have the same feature: the code and the text are separated by symbols. Therefore, we can extract the translatable text out and translate with CATs.
This short article shows how to translate the translatable text in a Joomla PHP language file.
Inside the Joomla PHP language file you will see:
DEFINE(“_NOT_AUTH”,”You are not authorised to view this resource.”);
DEFINE(“_DO_LOGIN”,”You need to login.”);
DEFINE(“_MAIN_INCLUDES_POSTMAIL”,”Thank you – you can now close this window.”);
DEFINE(“_MAIN_INCLUDES_RSS”,”Get the latest RSS feed listings”);
…and here are my steps:
- Select all text in your PHP file, copy & paste them into MS Excel (starting from the Column A, Row 1).
- Select all cells in the Column A, click the Data menu, click Text to Column, select the Delimited check box, and then click Next.
- In the Delimiters group box, click to clear Tab, Semicolon, Comma, and Space check boxes, select Other check box, type (“) without parentheses in the accompanying text box, and then click Finish.
- You should now have five columns: A, B, C, D, E. The text in the Column D is what you need to translate.
- Select all cells in the Column D, copy & paste into a new MS Word or Excel file for translating.
- Select all translated text, copy & paste into all cells in the Column D.
- Insert a new column between A and B, between C and D, between E and F, between G and H.
- Enter (“) without parentheses into all cells in four new columns B, D, F, H, which you got after insertions.
- Select the cell J1.
- For Excel 2003:
On the Insert menu, click Function, choose Text category, double-click the CONCATENATE function.
For Excel 2007:
On the Formulas tab, in the Function Library group, click Text, select the CONCATENATE function.
- The Function Arguments dialog box appears, enter:
A1 for Text1 box,
B1 for Text2 box,
C1 for Text3 box,
D1 for Text4 box,
E1 for Text5 box,
F1 for Text6 box,
G1 for Text7 box,
H1 for Text8 box,
I1 for Text9 box, and then click OK
- All PHP codes and your translation are now concatenated in the cell J1. Let’s copy the function and paste it into other cells in the Column J.
- Select all cells in the Column J, copy & paste over text on your PHP file. Now you got the final file for delivery.