Translation a PHP/MySQL-based website into a different language

Hey there,

Am new here. Could anyone please let me know how can I translate a PHP/MySQL based website into a different language?

I guess I need to create a folder with the name of that new language first. Do I need to copy all the files and folders falling under Public_html or just the .php files? How about the image folder or includes folder etc.

Any and all help is welcome.

Thanks and regards

Hi chikamiku, welcome to the forums.

Do you mean translate language as in “English->Spanish” or as in “PHP->Ruby”.

Thank you for the quick reply. I want to be able to translate pages as in English to Spanish etc. Will I need to create another database for, say, spanish as well?

Thanks

WordPress uses gettext to map messages to translations (in files). i.e. when the template pulls content from the database it substitutes the text in db content for that in the file before showing it. And there are several plugins that can translate as well.

IMHO the gettext route is better because it translates “messages” as opposed to “words”. For example, Google translate might (and might not) do a fairly good job, but even if the “best choice” is used the sentence structure could be wrong. But gettext requires that people fluent in both languages do the translating. Much more labor intensive.

Assuming your images don’t contain text you shouldn’t need to change those.

If you aren’t going to have a lot of different languages I guess you could have different database tables for each. But if content is going to be changed or added often this could be a maintenance nightmare.

Thanks for te feedback. But, did I mention anywhere that I was using Wordpress. I had said that I had made a simple PHP based website. Sorry for that.

Thanks anyway. Maybe someone know what i am talking about.

No, you didn’t say you were using WordPress, I gave that as an example of how the problem might be approached.

Do yo have a lot of pages? If few will they change often?

Thank you so much for the reply again. These pages will not change much. Not very many pages though.

I’ve been thinking of how I would do it if I had only a few static pages that didn’t change often.

I think I would set a SESSION value for the language choice, then on each page test for it and do something like (pseudo-code)

if (SESSION[‘language’] == ‘spanish’){
echo ‘spanish text’;
}else{
echo ‘english text’;
}

or if that made the code messy use include to get separate files instead.

Of course if the site grows, this way could become a maintainance headache, depending.