Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Apr 2003
    Location
    Montreal, QC
    Posts
    340
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Multi-Language Support

    Hi,

    I have a website, written in PHP/MySQL, that I need to add support for multiple languages to. There isn't a lot of text on it, mostly a bunch of short sentences and phrases, so I don't want to make a copy of all of the files, I'd just like to have a setting, probably a session variable, that stores the current display language, and based on the value of that variable output the page in the correct language.

    What are everyone's opinions on the best way to do this, (at least everyone who cares to contribute)?

    Should I dump all of my text into an include file and assign it to variables or constants - then just include the file for the correct language? (This is how oscommerce does it).

    Should I store all the text in a DB table "LANGUAGE" or something and only retrieve the stuff I need for a particular page? (this gives me easier storage for some info, and I don't have to worry about manually escaping stuff the same way, but it makes it harder to edit the text).

    Are there other options? I want to create a system that is scalable so that languages can be added or removed easily.

    Thanks in advance for the input!

    John
    Search for Laughter or Just Search?
    GiggleSearch.org
    Blog: www.johnbeales.com
    All About Ballet: www.the-ballet.com

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    You have the right idea mate.
    Only done one before, I used a prefetched DB design. Not sure if anything I can compare it to, but all I do is determine from a script level which "groups" of languages are required, this was necessary for the staggering amount of text involved, and it would have been far too much overhead to query the entire database for all languages for all text phrases.
    Then I just shoved those into variables (more specifically, a language object variable so I could access via a language object), and replaced those into my templates.

    However, my templates are also stored in the database, so storing the text also seemed like a logical route to follow. If you are currently on a filesytem based templates, I'd recommend sticking with it and simply storing your phrases in a files instead (one per line kind of idea).

    If this is your first time doing this, I'd say your already well on your way, most of what you where talking about is exactly what I did with mine (balancing the overhead with the required values)

    Good luck on the project mate!
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Regular Coder
    Join Date
    Apr 2003
    Location
    Montreal, QC
    Posts
    340
    Thanks
    3
    Thanked 2 Times in 2 Posts
    That's encouraging!

    I'm thinking about going the DB route because then the site won't have to load all of the text all of the time, and because there are a couple of longer items that need to be stored, (terms of use, privacy policy, that stuff), that would require an alternate system if I was storing stuff in files.

    I'm already using the DB pretty heavily - just not for text, ironically, so a lot of the code is already in place.
    Search for Laughter or Just Search?
    GiggleSearch.org
    Blog: www.johnbeales.com
    All About Ballet: www.the-ballet.com

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Good idea, you won't have any problem putting one together.
    Best of luck to you!
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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