Hello,
Since my little PHP site is expanding, Im running into troubles I never expected. Who would've thought foreigners would want my site in their language.
So now I have to convert semi-complex PHP like for example
from:
$CONTENT .= "Dear ".$thenickname.", to login, click <a href=\"login.php".sesInfo()."&blah=$yada\">Here</a>";
to:
$CONTENT .= $_hello_string.$thenickname.$_login_part1_message."<a href=\"login.php".sesInfo()."&blah=$yada\">$_login_here_text</a>";
And a file lang_en.inc containing:
$_hello_string = "Dear ";
$_login_part1_message = ", to login, click ";
$_login_here_text = "Here";
You get the general idea.. (I hope). The functions, stringnames and php filenames are all english and can stay that way, the inline text has to go.
Bottomline is, doing the above example just took me hmm, 1 minute to do. Now I'm sure I'll get better and more efficient at it when time progresses but what would be HUGELY efficient is a program that
1/ parses the PHP a bit
2/ replaces all 'language' (anything inbetween " or ' I guess) with strings that have auto-generated names, $string1, $string2, whatever.
3/ mix and match a bit to remove obvious redundancy. It just shouldnt fragment sentences, its nice to replace each occurrence of "Welcome to the " with a reusable $welcome, but not with "$welcome $to $the" (duh)
4/ since it auto-assigns variables, then launch an editor of sorts where I can rename the variables myself
5/ rename the auto-assigned variables to what I chose in #4 into the real code.
And presto. International code. I think. Obviously it doesn't have to be 'spiffy looking'.. the main obstacle I think is program the PHP parser that can rip the strings out of the right places without damaging the code. The renaming of the variables can be easily done by just demanding of the user(me) to not re-sort the temporary .inc file or change the original .php before the variable naming work is done.
Or... are there better tools to make code international-aware? My site is still semi-lightweight really, so I don't think I need something 'industry strenght'. It is conceivable that Id want to pull the language text out of a database, but I dont think that will change my problem structurally.
Suggestions wanted 😛