SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,446
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)
    Hi chikamiku, welcome to the forums.

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

  3. #3
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,446
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)
    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.

  5. #5
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,446
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)
    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?

  7. #7
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you so much for the reply again. These pages will not change much. Not very many pages though.

  8. #8
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,446
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)
    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.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •